Remarks

The FormatCondition object is a member of the collection. The FormatConditions collection can contain up to three conditional formats for a given range.

Use the method to create a new conditional format. If a range has mulitple formats, you can use the method to change one of the formats, or you can use the method to delete a format and then use the Add method to create a new format.

Use the , , and properties of the FormatCondition object to control the appearance of formatted cells. Some properties of these objects aren't supported by the conditional format object model. The properties that can be used with conditional formatting are listed in the following table.

Object Properties
Bold

Color

ColorIndex

FontStyle

Italic

Strikethrough

Underline

The accounting underline styles cannot be used.

Bottom

Color

Left

Right

Style

The following border styles can be used (all others aren't supported): xlNone, xlSolid, xlDash, xlDot, xlDashDot, xlDashDotDot, xlGray50, xlGray75, and xlGray25.

Top

Weight

The following border weights can be used (all others aren't supported): xlWeightHairline and xlWeightThin.

Color

ColorIndex

Pattern

PatternColorIndex

Example

Use (), where is the index number of the conditional format, to return a FormatConditionobject. The following example sets format properties for an existing conditional format for cells E1:E10.

Visual Basic for Applications
With Worksheets(1).Range("e1:e10").FormatConditions(1) With .Borders .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 6 End With With .Font .Bold = True .ColorIndex = 3 End With End With
Format Condition Object FormatCondition FormatCondition Object FormatCondition object?

See also:

index index