Class Validation (Excel VBA)

The class Validation represents data validation for a worksheet range.

The main procedures of class Validation are Add and Delete


To use a Validation class variable it first needs to be instantiated, for example

Dim vld as Validation
Set vld = ActiveCell.Validation

Validation class variables can be set using the Range.Validation procedure.


Some procedures in this class have been grouped together in themes and are described on separate theme pages

Name with its procedures ErrorTitle and InputTitle
Formula with its procedures Formula1 and Formula2
Display/Show with its procedures ShowError and ShowInput


These are the main methods of the Validation class

Add - Adds data validation to the specified range.

ActiveCell.Validation.Add Type:=xlValidateCustom

Delete - Deletes the object.


Other Methods

Modify - Modifies data validation for a range.


AlertStyle returns the validation alert style.

ErrorMessage returns or sets the data validation error message.

IgnoreBlank true if blank values are permitted by the range data validation.

IMEMode returns or sets the description of the Japanese input rules. Can be one of the XlIMEMode constants listed in the following table.

InCellDropdown true if data validation displays a drop-down list that contains acceptable values.

InputMessage returns or sets the data validation input message.

Operator returns a Long value that represents the operator for the data validation. See XlFormatConditionOperator.

Parent returns the parent object for the specified object. Read-only.

Type returns a Long value containing an XlDVType constant that represents the data type validation for a range.

Value returns a Boolean value that indicates if all the validation criteria are met (that is, if the range contains valid data).