Sub scode2()
Dim a, b
Dim ua(), ub()
Dim qa() As Boolean, qb() As Boolean
Dim rwa As Long, rwb As Long
Dim ka As Long, kb As Long
Dim i As Long, j As Long
rwa = Range("A" & Rows.Count).End(3).Row + 1
rwb = Range("B" & Rows.Count).End(3).Row + 1
ReDim ua(1 To rwa, 1 To 1), ub(1 To rwb, 1 To 1)
ReDim qa(rwa), qb(rwb)
a = Range("A1").Resize(rwa)
b = Range("B1").Resize(rwb)
For i = 1 To rwa
If qa(i) = False Then
For j = i + 1 To rwa
If qa(j) = False Then
If a(i, 1) = a(j, 1) Then qa(j) = True
End If
Next j
End If
Next i
For i = 1 To rwb
If qb(i) = False Then
For j = i + 1 To rwb
If qb(j) = False Then
If b(i, 1) = b(j, 1) Then qb(j) = True
End If
Next j
End If
Next i
For i = 1 To rwa
If qa(i) = False Then
For j = 1 To rwb
If qb(j) = False Then
If a(i, 1) = b(j, 1) Then
qa(i) = True
qb(j) = True
End If
End If
Next j
End If
Next i
For i = 1 To rwa
If qa(i) = False Then ka = ka + 1: ua(ka, 1) = a(i, 1)
Next i
For j = 1 To rwb
If qb(j) = False Then kb = kb + 1: ub(kb, 1) = b(j, 1)
Next j
If ka > 0 Then Range("D1").Resize(ka) = ua
If kb > 0 Then Range("E1").Resize(kb) = ub
End Sub