Skip to main content

FormatConditions object

Table of contents
  1. Remarks
  2. Example

Represents the collection of conditional formats for a single range.

Remarks

The FormatConditions collection can contain multiple conditional formats. Each format is represented by a FormatCondition object.

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

Example

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

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>