'Declaration Public Overloads Sub SetFormula( _ ByVal formula As System.String, _ ByVal address As System.String, _ ByVal format As WorkbookFormat, _ ByVal cellReferenceMode As CellReferenceMode, _ ByVal culture As System.Globalization.CultureInfo _ )
public void SetFormula( System.string formula, System.string address, WorkbookFormat format, CellReferenceMode cellReferenceMode, System.Globalization.CultureInfo culture )
Exception | Description |
---|---|
System.ArgumentNullException | Occurs when formula is null and the rule is currently applied to a Worksheet. |
FormulaParseException | Occurs when formula is not a valid formula. |
System.ArgumentException | Occurs when address is not a valid cell or regions address. |
System.ComponentModel.InvalidEnumArgumentException | Occurs when format is not defined in the WorkbookFormat enumeration. |
System.ComponentModel.InvalidEnumArgumentException | Occurs when cellReferenceMode is not defined in the CellReferenceMode enumeration. |
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. When the data validation rule is applied to cells or regions, the references in the formula used by each individual cell will be shifted by the offset of the cell to the passed in address. For example, consider the formula specified is =B1 and the specified address is A1. If the data validation rule is then applied to the A5 cell, the formula is will use is =B5. However, if the references in the formula are absolute, such as =$B$1, the same formula will be applied 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.
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
View on GitHub