|  

» Set up conditional formatting for an area with VBA in Microsoft Excel

Question:
In the selected area, the maximum value is to be marked violet with a conditional formatting


Answer:
Enter following code in a standard module.







Sub ConditionalFormat()
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=" & Range("Field").Cells(1).Address(False, False) & _
"=MAX(" & Selection.Address & ")"
.FormatConditions(1).Interior.ColorIndex = 39
End With
End Sub



Rate This Tip
12 34 5
Rating: 1.86     Views: 20723
No comments have been submitted.
Click here to post comment
For Registered Users
Name
Comment Title
Comments