Share via


Modify Method [Excel 2003 VBA Language Reference]

Modify method as it applies to the FormatCondition object.

Modifies an existing conditional format.

expression.Modify(Type, Operator, Formula1, Formula2)

expression Required. An expression that returns a FormatCondition object.

XlFormatCondition

XlFormatCondition can be one of these XlFormatCondition constants.
xlCellValue
xlExpression

XlFormatConditionOperator

XlFormatConditionOperator can be one of these XlFormatConditionOperator constants.
xlBetween
xlEqual

xlGreater

xlGreaterEqual

xlLess

xlLessEqual

xlNotBetween

xlNotEqual

If Type, is xlExpression, the Operator argument is ignored.

Formula1   Optional Variant. The value or expression associated with the conditional format. Can be a constant value, a string value, a cell reference, or a formula.

Formula2   Optional Variant. The value or expression associated with the conditional format. Can be a constant value, a string value, a cell reference, or a formula..

Example

This example modifies an existing conditional format for cells E1:E10.

Worksheets(1).Range("e1:e10").FormatConditions(1) _
    .Modify xlCellValue, xlLess, "=$a$1"

Modify method as it applies to the Validation object.

Modifies data validation for a range.

expression.Modify(Type, AlertStyle, Operator, Formula1, Formula2)

expression Required. An expression that returns a Validation object.

XlDVType

XlDVType can be one of these XlDVType constants.
xlValidateCustom
xlValidateDate

xlValidateDecimal

xlValidateInputOnly

xlValidateList

xlValidateTextLength

xlValidateTime

xlValidateWholeNumber

XlDVAlertStyle

XlDVAlertStyle can be one of these XlDVAlertStyle constants.
xlValidAlertInformation
xlValidAlertStop

xlValidAlertWarning

XlFormatConditionOperator

XlFormatConditionOperator can be one of these XlFormatConditionOperator constants.
xlBetween
xlEqual

xlGreater

xlGreaterEqual

xlLess

xlLessEqual

xlNotBetween

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
xlInputOnly AlertStyle, Formula1, and Formula2 are not used.
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.
xlValidateList Formula1 is required; Formula2 is ignored. Formula1 must contain either a comma-delimited list of values or a worksheet reference to the list.
xlValidateDate, xlValidateDecimal, xlValidateTextLength, xlValidateTime, or xlValidateWholeNumber 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"

Applies to | FormatCondition Object | Validation Object

See Also | Formula1 Property | Formula2 Property | Operator Property