• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Conditional Format in VBA

Conditional Format is technically applied to cells, not "run", but yes, you can set them up or remove them via macros. Here's an example:

[pre]
Code:
Sub test()
With Range("A2")
'Add CF rule
.FormatConditions.Add Type:=xlExpression, Formula1:="=A1>1"
'Modify the rule's behavior
.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255 'Red pattern
.TintAndShade = 0
End With

'Delete CF rule
.FormatConditions.Delete
End Sub
[/pre]
 
Back
Top