lookforsmt
Registered User.
- Local time
- Today, 15:38
- Joined
- Dec 26, 2011
- Messages
- 672
Hello everyone
i am stuck with the below vba code. This code helps me to highlight a single column, however, i am trying to give it a range in s1 as "A1:AX100" and it gives me an error. Below is the code and any suggestions.
i am stuck with the below vba code. This code helps me to highlight a single column, however, i am trying to give it a range in s1 as "A1:AX100" and it gives me an error. Below is the code and any suggestions.
Code:
Sub HighlightCells()
Dim s1 As Worksheet, s2 As Worksheet
Dim lr As Long, lr2 As Long
Dim i As Long, j As Long
Set s1 = Sheets("Numbering")
Set s2 = Sheets("ABC")
lr = s1.Range("A" & Rows.Count).End(xlUp).Row
lr2 = s2.Range("C" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = 2 To lr
For j = 2 To lr2
If InStr(s1.Range("A" & i), s2.Range("C" & j)) > 0 Then
s1.Range("A" & i).Interior.ColorIndex = 6
End If
Next j
Next i
Application.ScreenUpdating = True
MsgBox "Review Completed"
End Sub