FormatConditions Collection Object [Excel 2003 VBA Language Reference]

Multiple objects

Represents the collection of conditional formats for a single range. The FormatConditions collection can contain up to three conditional formats. Each format is represented by a FormatCondition object.

Using the FormatConditions Collection

Use the FormatConditions property to return a FormatConditions object. Use the Add method to create a new conditional format, and use the Modify method to change an existing conditional format.

The following example adds a conditional format to cells E1:E10.

With Worksheets(1).Range("e1:e10").FormatConditions _
        .Add(xlCellValue, xlGreater, "=$a$1")
    With .Borders
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = 6
    End With
    With .Font
        .Bold = True
        .ColorIndex = 3
    End With
End With


If you try to create more than three conditional formats for a single range, the Add method fails. If a range has three formats, you can use the Modify method to change one of the formats, or you can use the Delete method to delete a format and then use the Add method to create a new format.

For more information about conditional formats, see the FormatCondition object.

Properties | Application Property | Count Property | Creator Property | Parent Property

Methods | Add Method | Delete Method | Item Method

Parent Objects | Range

Child Objects | Borders | Font | Interior