代表條件化格式。
註解
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
方法
屬性
- Application
- AppliesTo
- Borders
- Creator
- DateOperator
- Font
- Formula1
- Formula2
- Interior
- NumberFormat
- Operator
- Parent
- Priority
- PTCondition
- ScopeType
- StopIfTrue
- Text
- TextOperator
- Type
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。