Please somebody help me...

J

Jason

Hello. I am needing to do a conditional statement which
changes the cell shading. I've found Format/Conditional
Formatting, but I can only nest 3 levels down. I need to
nest 4 levels. If a, make cell shading red, b = blue, c
= yellow, and d = red. By default it needs to be none.
Can anyone offer a suggestion to help? I think I need to
use Functions, I can do an If then, but need to know how
to change the cell shading. TIA!!!!!!! Much appreciated.
 
C

Chong Moua

Hi Jason,

Try this...
-----------------------------------
Sub color()

Dim i As Integer

For i = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(i, "A") = "a" Then Cells
(i, "A").Interior.ColorIndex = 3
If Cells(i, "A") = "b" Then Cells
(i, "A").Interior.ColorIndex = 5
If Cells(i, "A") = "c" Then Cells
(i, "A").Interior.ColorIndex = 6
If Cells(i, "A") = "d" Then Cells
(i, "A").Interior.ColorIndex = 10
Next i

End Sub
 

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