AboveAverage 对象用于条件格式中的高于平均数视图,将颜色或填充应用于区域或指定内容。
所有的条件格式都包含在FormatConditions集合对象中,该对象是range集合的子对象。
也就是代码可以写成:
range(A1:A26).select
Selection.FormatConditions.AddAboveAverage
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority‘设置高于平均值视图优先级为1
Selection.FormatConditions(1).AboveBelow = xlAboveAverage‘设置凸显规则为高于平均值’
以下再设置字体颜色和填充:
Selection.FormatConditions(1).Font.Color = 255
Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
注意:
Selection.FormatConditions(1).AboveBelow = xlAboveAverage
AboveBelow属性返回或设置 XlAboveBelow 枚举的常量之一,指定条件格式规则查找高于或低于平均值范围或标准偏差的单元格值。
名称 值 Description
xlAboveAverage 0 高于平均值
xlAboveStdDev 4 高于标准偏差
xlBelowAverage 1 低于平均值
xlBelowStdDev 5 低于标准偏差
xlEqualAboveAverage 2 等于高于平均值
xlEqualBelowAverage 3 等于低于平均值