FormatCondition 对象 (Excel)

表示条件格式。

注释

FormatCondition 对象是 FormatConditions 集合的成员。 FormatConditions 集合现在可以包含给定范围的三个以上条件格式。

使用 FormatConditions 对象的 Add 方法创建新的条件格式。 如果区域具有多种格式,可以使用 Modify 方法更改其中一种格式,也可以使用 Delete 方法删除格式,然后使用 Add 方法创建新格式。

使用 FormatCondition 对象的 FontBordersInterior 属性可控制格式化单元格的外观。 条件格式对象模型不支持这些对象的某些属性。 下表列出了条件格式可用的一些属性。

Object 可用于条件格式的属性
Font BoldColorColorIndexFontStyleItalicStrikethroughThemeColorThemeFontTintAndShade下划线

无法使用会计下划线样式。
Borders () 不支持其他所有边框,可以使用以下边框: xlBottomxlLeftxlRightxlTop

) 不支持其他所有边框样式 (可以使用: xlLineStyleNonexlContinuousxlDashxlDotxlDashDotxlDashDotDotxlGray50xlGray75xlGray25

(不支持其他所有) ,可以使用以下边框权重: xlHairlinexlThin
Interior ColorColorIndexGradientPatternPatternColorPatternColorIndexPatternThemeColorPatternTintAndShadeThemeColorTintAndShade

示例

使用 FormatConditions (索引) ,其中 index 是条件格式的索引号,以返回 FormatCondition 对象。 下例为单元格 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

方法

属性

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。