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
 
S

Simon Lloyd

It's not a good idea to use vba if you don't have to, Excels own buil
in conditional format function is faster and more efficient, although o
very large spreadsheets can cause a problem


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

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


--
Simon Lloyd

Regards
Simon Lloyd
'Excel Chat' (http://www.thecodecage.com/forumz/chat.php)
 

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