Excel) (AboveAverage 物件
代表設定格式化條件規則的高於平均視覺化。 將色彩或填滿套用至範圍或選取範圍,以協助您查看相對於其他儲存格的儲存格值。
註解
所有條件式格式化物件都包含在 FormatConditions 集合物件內,該集合物件是 Range 集合的子系。
您可以使用FormatConditions集合的Add或AddAboveAverage方法來建立高於平均格式化規則。
範例
下列範例會建立動態資料集,並透過設定格式化條件規則將色彩套用為高於平均的值。
Sub AboveAverageCF()
' Building data for Melanie
Range("A1").Value = "Name"
Range("B1").Value = "Number"
Range("A2").Value = "Melanie-1"
Range("A2").AutoFill Destination:=Range("A2:A26"), Type:=xlFillDefault
Range("B2:B26").FormulaArray = "=INT(RAND()*101)"
Range("B2:B26").Select
' Applying Conditional Formatting to items above the average. Should appear green fill and dark green font.
Selection.FormatConditions.AddAboveAverage
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).AboveBelow = xlAboveAverage
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
MsgBox "Added an Above Average Conditional Format to Melanie's data. Press F9 to update values.", vbInformation
End Sub
方法
屬性
- AboveBelow
- Application
- AppliesTo
- Borders
- CalcFor
- Creator
- Font
- Interior
- NumberFormat
- NumStdDev
- Parent
- Priority
- PTCondition
- ScopeType
- StopIfTrue
- Type
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。