I need VBA help please!!!

Closed
mdubyade - Jan 21, 2010 at 11:15 AM
 WutUP - Jan 21, 2010 at 09:24 PM
Hello,
I need help trying to write a vba code that will look at a column of data and see weather if the cell is red or green, and in a column of data next to it, i would like to highlight the adjacent cell in the same color. The colors in the first row are set conditionally based on the values that i have entered in another cell. For example if the first 5 cells are green in the first column, i want the first five cells in the other column to be green also, but if it changes to the first 10 cells are green, then in the other column i want the first 10 to be green also.

1 response

Hope this helps!


Sub CheckColor()

Dim i
Dim LastRow
i = 1
LastRow = Range("A65536").End(xlUp).Row

For i = i To LastRow

If Range("A" & i).Interior.ColorIndex = 10 Then

Range("B" & i).Select
With Selection.Interior
.ColorIndex = 10
.Pattern = xlSolid
End With

ElseIf Range("A" & i).Interior.ColorIndex = 3 Then

Range("B" & i).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With

ElseIf Range("A" & i).Interior.ColorIndex = xlNone Then

Range("B" & i).Select
With Selection.Interior
.ColorIndex = xlNone
End With

End If

Next i

Range("A1").Select

End Sub
0