Version

GetFormula(String,WorkbookFormat,CellReferenceMode,CultureInfo) Method

Gets the formula used to validate the value applied to a cell.
Syntax
'Declaration
 
Public Overloads Function GetFormula( _
   ByVal address As System.String, _
   ByVal format As WorkbookFormat, _
   ByVal cellReferenceMode As CellReferenceMode, _
   ByVal culture As System.Globalization.CultureInfo _
) As System.String
public System.string GetFormula( 
   System.string address,
   WorkbookFormat format,
   CellReferenceMode cellReferenceMode,
   System.Globalization.CultureInfo culture
)

Parameters

address
The address of the cell or region that serves as the basis for relative references, or null to use the top-left cell of the worksheet.
format
The workbook format with which to parse address.
cellReferenceMode
The cell reference mode with which to parse address.
culture
The culture to use when generating the formula string.

Return Value

A formula used to validate the value applied to a cell.
Exceptions
ExceptionDescription
System.ArgumentExceptionOccurs when address is not a valid cell or regions address.
System.ComponentModel.InvalidEnumArgumentExceptionOccurs when format is not defined in the WorkbookFormat enumeration.
System.ComponentModel.InvalidEnumArgumentExceptionOccurs when cellReferenceMode is not defined in the CellReferenceMode enumeration.
Remarks

The formula will indicate the value is invalid by evaluating to False, 0, any ErrorValue (such as #VALUE!), or any string other than "True" (case-insensitive). True, "True" (case-insensitive), null, and non-zero numeric values will indicate a valid value has been applied.

The address passed in is only needed if relative addresses are used in the the formula. For example, consider the formula applied is =B1, and the data validation rule is applied to the region A1:A5. If you get the formula for A1, the formula =B1 will be returned. If you get the formula for A2, =B2 will be returned. Similarly, for cell A5, =B5 will be returned. However, if the formula contains no references or all absolute references, the address is ignored. So in the previous example, if the original formula was =$B$1, the same formula will be returned regardless of the specified address.

address can be any valid cell or region reference on a worksheet. If a region address is specified, the top-left cell or the region is used. The cell or region specified does not need to have the data validation rule applied to it. Any reference is allowed.

Requirements

Target Platforms: Windows 8.1, Windows 8.1, Windows 8, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

View on GitHub