Hi
I am trying to create a VBA sub to highlight an entire row based on a partial string value in column "AK"
My error occurs at code line " If InStr(Cells(i, "AK").Value, "L-") Then "
I have a sheet with about 2000 rows of data and I run this reports and probably in 2 dozen of these rows there will be an entry in column "AK" that starts with "L-" and then a string of different numbers. I need to loop down the column and identify these records and highlight the row.
I searched the web before posting and it seems like my code is OK but I am obviously off with my syntax or approach all together.
Thank you for the help.
I am trying to create a VBA sub to highlight an entire row based on a partial string value in column "AK"
My error occurs at code line " If InStr(Cells(i, "AK").Value, "L-") Then "
I have a sheet with about 2000 rows of data and I run this reports and probably in 2 dozen of these rows there will be an entry in column "AK" that starts with "L-" and then a string of different numbers. I need to loop down the column and identify these records and highlight the row.
I searched the web before posting and it seems like my code is OK but I am obviously off with my syntax or approach all together.
Thank you for the help.
VBA Code:
sub highlightRow()
Dim lrow, i As Long
lrow = Cells(Rows.Count, "B").End(xlUp).Row
i = 2
Columns("AK:AK").Select
Do While i <= lrow
If InStr(Cells(i, "AK").Value, "L-") Then
Range(Cells(i, 1), Cells(i, 45)).Interior.Color = RGB(167, 220, 233)
End If
i = i + 1
Loop
End Sub