Validation.Add(XlDVType, Object, Object, Object, Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds data validation to the specified range.
public void Add (Microsoft.Office.Interop.Excel.XlDVType Type, object AlertStyle, object Operator, object Formula1, object Formula2);
Public Sub Add (Type As XlDVType, Optional AlertStyle As Object, Optional Operator As Object, Optional Formula1 As Object, Optional Formula2 As Object)
Parameters
- AlertStyle
- Object
Optional Object. The validation alert style. Can be one of the following XlDVAlertStyle constants: xlValidAlertInformation, xlValidAlertStop, or xlValidAlertWarning.
- Operator
- Object
Optional Object. The data validation operator. Can be one of the following XlFormatConditionOperator constants: xlBetween, xlEqual, xlGreater, xlGreaterEqual, xlLess, xlLessEqual, xlNotBetween, or xlNotEqual.
- Formula1
- Object
Optional Object. The first part of the data validation equation.
- Formula2
- Object
Optional Object. The second part of the data validation when Operator
is xlBetween or xlNotBetween (otherwise, this argument is ignored).
Remarks
The Add method requires different arguments, depending on the validation type, as shown in the following table.
xlValidateCustom | Formula1 is required; Formula2 is ignored. Formula1 must contain an expression that evaluates to True when data entry is valid and False when data entry is invalid. |
xlInputOnly | AlertStyle , Formula1 , or Formula2 are used. |
xlValidateList | Formula1 is required; Formula2 is ignored. Formula1 must contain either a comma-delimited list of values or a worksheet reference to this list. |
xlValidateWholeNumber, xlValidateDate, xlValidateDecimal, xlValidateTextLength, or xlValidateTime | One of either Formula1 or Formula2 must be specified, or both may be specified. |