Validation.Add Method
Adds data validation to the specified range.
Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)
Syntax
'Declaration
Sub Add ( _
Type As XlDVType, _
AlertStyle As Object, _
Operator As Object, _
Formula1 As Object, _
Formula2 As Object _
)
'Usage
Dim instance As Validation
Dim Type As XlDVType
Dim AlertStyle As Object
Dim Operator As Object
Dim Formula1 As Object
Dim Formula2 As Object
instance.Add(Type, AlertStyle, Operator, _
Formula1, Formula2)
void Add(
XlDVType Type,
Object AlertStyle,
Object Operator,
Object Formula1,
Object Formula2
)
Parameters
Type
Type: Microsoft.Office.Interop.Excel.XlDVTypeRequired XlDVType. The validation type.
AlertStyle
Type: System.ObjectOptional Object. The validation alert style. Can be one of the following XlDVAlertStyle constants: xlValidAlertInformation, xlValidAlertStop, or xlValidAlertWarning.
Operator
Type: System.ObjectOptional Object. The data validation operator. Can be one of the following XlFormatConditionOperator constants: xlBetween, xlEqual, xlGreater, xlGreaterEqual, xlLess, xlLessEqual, xlNotBetween, or xlNotEqual.
Formula1
Type: System.ObjectOptional Object. The first part of the data validation equation.
Formula2
Type: System.ObjectOptional 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.
Validation type |
Arguments |
---|---|
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. |