Hi,
The obvious choice would be the advanced filter. Choose both columns and then filter by unique entries.
Or
the code bellow will flag duplicate entries in red:
(www.techonthenet.com)
Sub TestForDups()
Dim LLoop As Integer
Dim LTestLoop As Integer
Dim LClearRange As String
Dim Lrows As Integer
Dim LRange As String
'Column A values
Dim LChangedValue As String
Dim LTestValue As String
'Column B values
Dim LChangedValueB As String
Dim LTestValueB As String
'Test first 200 rows in spreadsheet for uniqueness
Lrows = 200
LLoop = 2
'Clear all flags
LClearRange = "A2:B" & Lrows
Range(LClearRange).Interior.ColorIndex = xlNone
'Check first 200 rows in spreadsheet
While LLoop <= Lrows
LChangedValue = "A" & CStr(LLoop)
LChangedValueB = "B" & CStr(LLoop)
If Len(Range(LChangedValue).Value) > 0 Then
'Test each value for uniqueness
LTestLoop = 2
While LTestLoop <= Lrows
If LLoop <> LTestLoop Then
LTestValue = "A" & CStr(LTestLoop)
LTestValueB = "B" & CStr(LTestLoop)
'Value has been duplicated in another cell
If (Range(LChangedValue).Value = Range(LTestValue).Value) And (Range(LChangedValueB).Value = Range(LTestValueB).Value) Then
'Set the background color to red in column A
Range(LChangedValue).Interior.ColorIndex = 3
Range(LTestValue).Interior.ColorIndex = 3
'Set the background color to red in column B
Range(LChangedValueB).Interior.ColorIndex = 3
Range(LTestValueB).Interior.ColorIndex = 3
End If
End If
LTestLoop = LTestLoop + 1
Wend
End If
LLoop = LLoop + 1
Wend
End Sub
Bookmarks