Hi,
I am trying to cycle through the rows of the worksheet and if the value in Column D is London I want that row to be coloured.
However, I keep getting a runtime error and can't work out why. This is the code below:
Sub ColorRows()
Dim lastRow As Long
Dim i As Long
lastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
For i = 1 To lastRow
If ActiveSheet.Cells(i, "D").Value = "London" Then
ActiveSheet.Range("A" & i & ":BJ" & i).Interior.Color = RGB(254, 241, 207)
End If
Next i
End Sub
Any help would be much appreciated.
Thank you
I am trying to cycle through the rows of the worksheet and if the value in Column D is London I want that row to be coloured.
However, I keep getting a runtime error and can't work out why. This is the code below:
Sub ColorRows()
Dim lastRow As Long
Dim i As Long
lastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
For i = 1 To lastRow
If ActiveSheet.Cells(i, "D").Value = "London" Then
ActiveSheet.Range("A" & i & ":BJ" & i).Interior.Color = RGB(254, 241, 207)
End If
Next i
End Sub
Any help would be much appreciated.
Thank you