Modify Method (Validation Object)

Applies To

Validation object.

Description

Modifies data validation for a range.

Syntax

expression.Modify(Type, AlertStyle, Minimum, Maximum)

expression Required. An expression that returns a Validation object.

Type Required Long. The validation type. Can be one of the following XlDVType constants: xlValidateCustom, xlValidateDate, xlValidateDecimal, xlValidateInputOnly, xlValidateList, xlValidateTextLength, xlValidateTime, or xlValidateWholeNumber.

AlertStyle Optional Variant. The validation alert style. Can be one of the following XlDVAlertStyle constants: xlValidAlertInformation, xlValidAlertStop, or xlValidAlertWarning.

Operator Optional Variant. The data validation operator. Can be one of the following XlFormatConditionOperator constants: xlBetween, xlEqual, xlGreater, xlGreaterEqual, xlLess, xlLessEqual, xlNotBetween, or xlNotEqual.

Formula1 Optional Variant. The first part of the data validation equation.

Formula2 Optional Variant. The second part of the data validation when Operator is xlBetween or xlNotBetween (otherwise, this argument is ignored).

Remarks

The Modify 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, and Formula2 are not used.

xlValidateList

Formula1 is required; Formula2 is ignored. Formula1 must contain either a comma-delimited list of values or a worksheet reference to the list.

xlValidateWholeNumber, xlValidateDate, xlValidateDecimal, xlValidateTextLength, or xlValidateTime

Formula1 or Formula2, or both, must be specified.


Example

This example changes data validation for cell E5.

Range("E5").Validation _
    .Modify xlValidateList, xlValidAlertStop, xlBetween, "=$A$1:$A$10"