'Declaration Public Overloads Sub SetUpperConstraintFormula( _ ByVal upperConstraintFormula As String, _ ByVal address As String, _ ByVal format As WorkbookFormat, _ ByVal cellReferenceMode As CellReferenceMode, _ ByVal culture As CultureInfo _ )
public void SetUpperConstraintFormula( string upperConstraintFormula, string address, WorkbookFormat format, CellReferenceMode cellReferenceMode, CultureInfo culture )
Exception | Description |
---|---|
System.ArgumentNullException | Occurs when upperConstraintFormula is null and the rule is currently applied to a Worksheet. |
System.ArgumentException | Occurs when upperConstraintFormula is an ArrayFormula. |
System.ArgumentException | Occurs when address is not a valid cell or regions address. |
System.ArgumentNullException | Occurs when the specified value is null and the rule is currently applied to a Worksheet. |
FormulaParseException | Occurs when upperConstraintFormula is not a valid formula. |
System.ArgumentException | Occurs when the specified value equals a constant, such as =5, and the constant value is greater than the upper constraint value. If the upper constraint formula does not equal a constant, this verification is not performed. |
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 way in which the cell value is compared to the upper constraint formula's value is determined by the ValidationOperator as well as the ValueConstraintDataValidationRule.ValidationCriteria.
Depending on the ValidationCriteria of the rule, either the cell value itself or the length of the cell value's text equivalent is compared to the upper constraint formula's value.
When the ValidationOperator is Between, the value must be greater than or equal to the lower constraint and less than or equal to the upper constraint. When the ValidationOperator is NotBetween, the value must be less than the lower constraint or greater than the upper constraint.
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 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, 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
TwoConstraintDataValidationRule Class
TwoConstraintDataValidationRule Members
Overload List
SetUpperConstraint(Double) Method
SetUpperConstraint(DateTime) Method
SetUpperConstraint(TimeSpan) Method
GetUpperConstraintFormula(String) Method
GetUpperConstraintFormula(String,WorkbookFormat,CellReferenceMode,CultureInfo) Method
SetLowerConstraintFormula(String,String) Method
SetLowerConstraintFormula(String,String,WorkbookFormat,CellReferenceMode,CultureInfo) Method
SetUpperConstraintFormula(String,String) Method
ValidationOperator Property
ValidationCriteria Property