PDA

View Full Version : Changing color of part of Row if condition met



kurtwagner
12-06-2012, 06:07 AM
Hello, I'm working on a macro to change the color of the row between column W to AN if in column K the value is "FCA" (without quotes).
So far I have this, but it doesn't work:



Sub Test()

For Each cell In Range("K1", Cells(Rows.Count,
"K").End(xlUp))
If InStr(1, cell, "FCA")
Then
Range("W" & cell.Row & ":AN" &
cell.Row).Interior.ColorIndex = 3
End If
Next
cell

patel
12-06-2012, 06:40 AM
Sub Test()
LR = Cells(Rows.Count, "K").End(xlUp).Row
For Each cell In Range("K1:K" & LR)
If InStr(cell, "FCA") > 0 Then
Range("W" & cell.Row & ":AN" & cell.Row).Interior.ColorIndex = 3
End If
Next cell
end sub