`

AboveAverage 对象 (Excel)

    博客分类:
  • VBA
VBA 
阅读更多
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 -为此条件格式规则设置求值顺序,以便在工作表上的所有其他规则之后计算此规则
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics