FormatCondition object (Excel)
Represents a conditional format.
Remarks
The FormatCondition object is a member of the FormatConditions collection. The FormatConditions collection can now contain more than three conditional formats for a given range.
Use the Add method of the FormatConditions object to create a new conditional format. If a range has multiple 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.
Use the Font, Borders, and Interior 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. Some of the properties that can be used with conditional formatting are listed in the following table.
Object | Properties you can use with conditional formatting |
---|---|
Font | Bold, Color, ColorIndex, FontStyle, Italic, Strikethrough, ThemeColor, ThemeFont, TintAndShade, and Underline The accounting underline styles cannot be used. |
Borders | The following borders can be used (all others aren't supported): xlBottom, xlLeft, xlRight, xlTop. The following border styles can be used (all others aren't supported): xlLineStyleNone, xlContinuous, xlDash, xlDot, xlDashDot, xlDashDotDot, xlGray50, xlGray75, and xlGray25. The following border weights can be used (all others aren't supported): xlHairline and xlThin. |
Interior | Color, ColorIndex, Gradient, Pattern, PatternColor, PatternColorIndex, PatternThemeColor, PatternTintAndShade, ThemeColor, and TintAndShade. |
Example
Use FormatConditions (index), where index is the index number of the conditional format, to return a FormatCondition object. The following example sets format properties for an existing conditional format for cells E1:E10.
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
Methods
Properties
- Application
- AppliesTo
- Borders
- Creator
- DateOperator
- Font
- Formula1
- Formula2
- Interior
- NumberFormat
- Operator
- Parent
- Priority
- PTCondition
- ScopeType
- StopIfTrue
- Text
- TextOperator
- Type
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.