Change cell color

  • Thread starter Thread starter Johan
  • Start date Start date
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.
 
Try the below

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