I'm looking for solution how to fill range od cell with color depend of value.
I've attached the file.
There is special row 9.
Value of the cell in the row 9 depend of value in the cell in row 6.
For example:
- if left cell in row 6 is empty the value of row 9 is 1.
- if left cell in row 6 is the same the value of row 9 is the same like in the left cell
- if left cell in row 6 is different the value of row 9 is the same like in the left cell +1
I can cut and paste cells in row 6 and all with values in row 9 working fine.
ok, and now if value in row 9 is > 0 I would like to fill row from 6 to 9 with color.
I'd like to achieve something like this:
- If value in row 9 is 1 then color in this column for row from 6 to 9 is blue
- If value in row 9 is 2 then color in this column for row from 6 to 9 is red
- If value in row 9 is 2 then color in this column for row from 6 to 9 is green
....
For example (according to the file in attached):
-if value D9 is 1 then D6-D9 is filled with blue
-if value F9 is 1 then F6-F9 is filled with blue
-if value G9 is 1 then G6-G9 is filled with blue
-if value H9 is 2 then H6-H9 is filled with red
-if value J9 is 1 then J6-J9 is filled with blue
-if value K9 is 2 then K6-K9 is filled with red
-if value L9 is 3 then L6-L9 is filled with green
...and so on
I found code like below, but because I'm not a codder I can't addapt this code for what I would like to achieve.
Could someone help ?
Sub ColorMeElmo()
Dim i As Long, r1 As Range, r2 As Range
For i = 2 To 5
Set r1 = Range("D" & i)
Set r2 = Range("A" & i & ":C" & i)
If r1.Value = 1 Then r2.Interior.Color = vbRed
If r1.Value = 2 Then r2.Interior.Color = vbBlue
If r1.Value = 3 Then r2.Interior.Color = vbYellow
Next i
End Sub
Bookmarks