Hello newbie1234,
Sorry for delay. My cats were wanting to play with the computer cables. It's late and they're bored. Anyway, the following macro is attached to a button on "Sheet1". Click this and it color the rows that match what is in "I1", i.e. the "WWWW", "LLLL", "WWW", and "LLL" combinations.
Sub ColorCell()
Dim Cell As Range
Dim ColorArray(1 To 4)
Dim I As Integer
Dim Rng As Range
Dim S As String
With Worksheets("Sheet1")
S = .Range("I1")
Set Rng = .Range(.Cells(2, "F"), .Cells(.Rows.Count, "F").End(xlUp))
For I = 1 To 4
ColorArray(I) = .Cells(I + 1, "P").Interior.ColorIndex
Next I
For Each Cell In Rng
A = Cell.Address
If Cell = S Then
Select Case Cell
Case "LLL"
Cell.Offset(0, -5).Resize(, 5).Interior.ColorIndex = ColorArray(1)
Case "WWW"
Cell.Offset(0, -5).Resize(, 5).Interior.ColorIndex = ColorArray(2)
Case "LLLL"
Cell.Offset(0, -5).Resize(, 5).Interior.ColorIndex = ColorArray(3)
Case "WWWW"
Cell.Offset(0, -5).Resize(, 5).Interior.ColorIndex = ColorArray(4)
End Select
End If
Next Cell
End With
End Sub
Sincerely,
Leith Ross
Bookmarks