VBA to color cells baised on cell above

[Closed]
Report
Posts
2
Registration date
Tuesday August 11, 2015
Status
Member
Last seen
August 11, 2015
-
Posts
2
Registration date
Tuesday August 11, 2015
Status
Member
Last seen
August 11, 2015
-
Hello,
Im working with this.....

PURPLE BLUE GREEN YELLOW RED GREY
Ratio 6089 1178 14827 15676.5 2373 25382
24356 35349 29654 31353 23731 25382
4 3 2 2 1 1

Im looking for vba that will color the cells in the "ratio" row, depending on the team name (color) listed above. The possition of these colors is based on rank and there for will be constantly changing possition.

So 6089 needs to be purple, 1178 needs to be blue, etc.

This is what i wrote, but it isnt working. help please!

Sub CellColorsDefine()
lRow = Range("M" & Rows.Count).End(xlUp).Row
Set MR = Range("M27:M" & lRow)
For Each cell In MR
If cell.Value = "RED" Then cell.Interior.ColorIndex = 3
If cell.Value = "PURPLE" Then cell.Interior.ColorIndex = 13
If cell.Value = "BLUE" Then cell.Interior.ColorIndex = 5
If cell.Value = "GREEN" Then cell.Interior.ColorIndex = 4
If cell.Value = "GREY" Then cell.Interior.ColorIndex = 16
If cell.Value = "YELLOW" Then cell.Interior.ColorIndex = 6
Next
End Sub


1 reply

Posts
2
Registration date
Tuesday August 11, 2015
Status
Member
Last seen
August 11, 2015

a better image of what im using looks like...