欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

AboveAverage 对象 (Excel)

程序员文章站 2024-01-27 15:56:46
...
AboveAverage 对象 (Excel)
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


引用

AboveAverage
.Delete -删除指定的条件格式规则对象
.ModifyAppliesToRange( _Range_ ) -设置此格式规则所应用于的单元格区域
.SetFirstPriority -将此条件格式规则的优先级值设置为“1”,以便在工作表上的所有其他规则之前计算此规则
.SetLastPriority -为此条件格式规则设置求值顺序,以便在工作表上的所有其他规则之后计算此规则
相关标签: VBA