Discussion Locked

Dynamic setting of cell's color

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can I dynamically set cell's color in Excel?
It seems that color is not considered as a property with built-in functions to handle it.

Any advice?
Ben

5 replies

by mjrebholz

It depends what you mean by dynamically in this case, Ben. Typically, you might want the color of a cell or the font to change based on a set of criteria (for example, if cell A3 is greater than the value in B5, then show cell C5 in red.)

This iscalled conditional formatting. Go to the "format" menu, then "conditional formatting". You can then choose an 'argument' based on how you want the colour or appearance of cells or text to change under given circumstances. The "Border" tab under conditional formatting typically contains the features that will allow you to change the cell colour.

Regards

by wjhunt

Ben,
Here is some code that sets a cell's color:
Range("D5").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
You can wrap your conditionals around it...

This discussion is closed to new replies.