Sub perhab()
Dim a, b, c, i As Long, dic As Object
a = Range("A1:A" & Cells(Rows.Count, 1).End(3).Row).Value
b = Range("B1:B" & Cells(Rows.Count, 2).End(3).Row).Value
ReDim c(1 To 2)
c(1) = a: c(2) = b
Set dic = CreateObject("Scripting.Dictionary")
For i = 1 To 2
For j = 1 To UBound(c(i))
If Not dic.Exists(c(i)(j, 1)) Then
dic.Add c(i)(j, 1), Array(IIf(i = 2, i, ""), c(i)(j, 1))
Else
dic.Remove c(i)(j, 1)
End If
Next j
Next i
With Range("C1")
.Resize(dic.Count, 2).Value = Application.Index(dic.Items, 0, 0)
.EntireColumn.SpecialCells(2, 1).Resize(, 2).ClearContents
End With
End Sub
ANOTHER WAY
Sub anotherWay()
Dim a, i As Long
With Range("A1:A" & Cells(Rows.Count, 1).End(3).Row)
a = .Value
For i = 1 To UBound(a)
If Application.CountIf(Range("B:B"), a(i, 1)) > 0 Then
a(i, 1) = ""
End If
Next i
.Value = a
On Error Resume Next: .SpecialCells(4).Delete Shift:=xlUp: On Error GoTo 0
End With
End Sub
Bookmarks