共用方式為


FormatCondition 物件 (Excel)

代表條件化格式。

註解

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

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

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

物件 您可以與條件式格式搭配使用的屬性
Font BoldColorColorIndexFontStyleItalicStrikethroughThemeColorThemeFontTintAndShadeUnderline

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

下列框線樣式可以使用, () 不支援所有其他框線樣式: xlLineStyleNonexlContinuousxlDashxlDotxlDashDotxlDashDotxlGray50xlGray75xlGray25

下列邊框權重可用於 () 不支援所有其他權重: 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 支援與意見反應