FormatCondition 对象 (Excel)

表示条件格式。

注释

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

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

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

Object 可用于条件格式的属性
Font Bold、Color、ColorIndex、FontStyle、斜体、删除线、ThemeColor、ThemeFont、TintAndShade 和 Underline

不能使用会计下划线样式。
Borders 可以使用以下边框 () 不支持所有其他边框: xlBottom、 xlLeft、 xlRight、 xlTop。

可以使用以下边框样式 () 不支持所有其他样式: xlLineStyleNone、 xlContinuous、 xlDash、 xlDot、 xlDashDot、 xlDashDotDot、 xlGray50、 xlGray75 和 xlGray25。

可以使用以下边框权重 () 不支持所有其他权重: xlHairline 和 xlThin。
Interior Color、 ColorIndex、 Gradient、 Pattern、 PatternColor、 PatternColorIndex、 PatternThemeColor、 PatternTintAndShade、 ThemeColor 和 TintAndShade。

示例

在索引) (使用 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 支持和反馈,获取有关如何接收支持和提供反馈的指南。