Hi All,
Below is my code that I can't get to work...
The code works if I want to "Select" cells B and C if there is a duplicate. When I turn off the duplicate, and just want to highlight the duplicate pairs, an error message is thrown that says "subscript out of range". I would like to highlight pairs without having to select each one if that is possible. Thanks for reading my post and your help on this. --Ben
Below is my code that I can't get to work...
Code:
Sub find_dup_pairs()
Dim i As Long
Dim LastRow As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row
For i = LastRow To 1 Step -1
If Cells(i, 2) & Cells(i, 3) = Cells(i + 1, 2) & Cells(i + 1, 3) Then
'Range(Cells(i, 2), Cells(i, 3)).Select 'this works...
Range(Cells(i, 2), Cells(i, 3)).Interior.ColorIndex = 255 'this does not work...
End If
Next i
End Sub
The code works if I want to "Select" cells B and C if there is a duplicate. When I turn off the duplicate, and just want to highlight the duplicate pairs, an error message is thrown that says "subscript out of range". I would like to highlight pairs without having to select each one if that is possible. Thanks for reading my post and your help on this. --Ben