FormatCondition 对象

         
Range
FormatConditions (FormatCondition)
Borders (Border)
Font
Interior

代表一个条件格式。FormatCondition 对象是 FormatConditions 集合的成员。FormatConditions 集合最多可包含给定区域的三个条件格式。

FormatCondition 对象的用法

可用 FormatConditions(index) 返回一个 FormatCondition 对象,其中 index 为条件格式的索引号。下例将“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

说明

可用 Add 方法新建一个条件格式。如果试图为单个区域创建三个以上的条件格式,则 Add 方法失效。如果一个区域有三个格式,请使用 Modify 方法对这些格式进行修改,或者使用 Delete 方法删除某个格式,然后使用 Add 方法新建一个格式。

可用 FormatCondition 对象的 FontBorderInterior 属性控制已设定格式单元格的显示。条件格式对象模型不支持这些对象的某些属性。下表中列出所有可使用条件格式的属性。

对象 属性
Font Bold

Color

ColorIndex

FontStyle

Italic

Strikethrough

Underline

无法使用会计下划线样式。

Border Bottom

Color

Left

Right

Style

可使用下列边框样式(其他均不可用):xlNonexlSolidxlDashxlDotxlDashDotxlDashDotDotxlGray50xlGray75xlGray25

Top

Weight

可使用下列边框粗细(其他均不可用):xlWeightHairlinexlWeightThin

Interior Color

ColorIndex

Pattern

PatternColorIndex