Change cell color

J

Johan

How do i write a macro or VBA program that will change the color of a cell
based on set conditions?

eg. if the cell value <20 then change the color to red.
 
J

Jacob Skaria

Try the below

With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(RC<>"""",RC<20)"
.FormatConditions(1).Interior.ColorIndex = 3
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top