Excel) (FormatCondition 物件

代表條件化格式。

註解

FormatCondition 物件是 FormatConditions 集合的成員。 FormatConditions 集合最多可包含特定範圍的三個條件化格式。

使用 FormatConditions 物件的 Add 方法來建立新的條件式格式。 如果範圍有多種格式,您可以使用 Modify 方法變更其中一個格式,或者您可以使用 Delete 方法刪除格式,然後使用 Add 方法建立新格式。

使用 FormatCondition 物件的 Font、Borders 及 Interior 屬性可控制已設定格式的儲存格外觀。 條件式格式物件模型不支援這些物件的某些屬性。 下表會列出設定條件化格式時所能使用的屬性。

物件 可與條件式格式設定搭配使用的屬性
Font Bold、 Color、 ColorIndex、 FontStyle、 Italic、 Strikethrough、 ThemeColor、 ThemeFont、 TintAndShade 和 Underline

無法使用會計底線樣式。
Borders ) 不支援所有其他框線 (可以使用下列框線: xlBottom、 xlLeft、 xlRight、 xlTop。

(不支援所有其他框線樣式,可以使用以下框線樣式) :xlLineStyleNone、xlContinuous、xlDash、xlDot、xlDashDot、xlDashDot、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 支援與意見反應。