Find and delete Both Dupblicate Cells in a list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two lists. The list B contains some same cells with List A. How can I
find all the duplicate cells on list A and than delete both cells?
 
Enter and run this macro:

Sub myrto()
rw1 = Range("A" & Rows.Count).End(xlUp).Row
rw2 = Range("B" & Rows.Count).End(xlUp).Row

Set rDel = Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
For i = 1 To rw1
v1 = Cells(i, "A").Value
For j = 1 To rw2
v2 = Cells(j, "B").Value
If v1 = v2 Then
Set rDel = Union(rDel, Cells(i, "A"), Cells(j, "B"))
End If
Next
Next
rDel.Delete Shift:=xlUp
End Sub
 
Back
Top