Sub rowsandstuffrev()
Dim a, b, c(), ra(), rb(), p, q, z
a = Sheets("A").UsedRange
b = Sheets("B").UsedRange
na = UBound(a, 1): ma = UBound(a, 2)
nb = UBound(b, 1): mb = UBound(b, 2)
ReDim ra(1 To na), rb(1 To nb), c(1 To na, 1 To ma)
z = 6 'or whatever column number you want comparison to be up to.
If z > ma Or z > mb Then
MsgBox "Trying to compare more columns than are available." _
& Chr(10) & "Exiting code."
Exit Sub
End If
For i = 1 To na
For j = 1 To z
If j = 1 Then
ra(i) = a(i, j)
Else: ra(i) = ra(i) & Chr(30) & a(i, j)
End If
Next j, i
For i = 1 To nb
For j = 1 To z
If j = 1 Then
rb(i) = b(i, j)
Else: rb(i) = rb(i) & Chr(30) & b(i, j)
End If
Next j, i
For j = 1 To nb
For i = 1 To na
If ra(i) = rb(j) Then
p = p + 1
For k = 1 To ma
c(p, k) = a(i, k)
Next k
End If
Next i
Next j
For i = 1 To na
For j = 1 To nb
If ra(i) = rb(j) Then GoTo nxti
Next j
p = p + 1
For k = 1 To ma
c(p, k) = a(i, k)
Next k
ra(i) = Empty
nxti: Next i
For i = 1 To na
If Not IsEmpty(ra(i)) Then
q = q + 1
For j = 1 To ma
a(q, j) = a(i, j)
Next j
End If
Next i
Sheets("A").UsedRange.ClearContents
Sheets("B").UsedRange.ClearContents
Sheets("A").[a1].Resize(q, ma) = a
Sheets("B").[a1].Resize(p, mb) = c
End Sub