This is to amend your original code.
Sub test()
Dim arr1 As Variant
Dim arr2 As Variant
Dim arr3 As Variant
Dim coll As Collection
Dim i As Long, j As Long, ii As Long, txt As String, x
With Worksheets("Sheet2")
LastRowColumnA = .Cells(.Rows.Count, 1).End(xlUp).Row
arr1 = .Range("A1:C" & LastRowColumnA).Value
End With
With Worksheets("Sheet1")
LastRowColumnA = .Cells(.Rows.Count, 1).End(xlUp).Row
arr2 = .Range("A1:C" & LastRowColumnA).Value
End With
Set coll = New Collection
On Error Resume Next
For i = LBound(arr1, 1) To UBound(arr1, 1)
txt = Join(Array(arr1(i, 1), arr1(i, 2), arr1(i, 3)), Chr(2))
coll.Add txt, txt
Next i
For i = LBound(arr2, 1) To UBound(arr2, 1)
txt = Join(Array(arr2(i, 1), arr2(i, 2), arr2(i, 3)), Chr(2))
Err.Clear
coll.Add txt, txt
If Err.Number <> 0 Then coll.Remove txt
Next i
ReDim arr3(1 To coll.Count, 1 To 3)
For i = 1 To coll.Count
x = Split(coll(i), Chr(2))
For ii = 0 To 2
arr3(i, ii + 1) = x(ii)
Next
Next i
Worksheets("Sheet2").Range("F1").Resize(UBound(arr3, 1), 3).Value = arr3
End Sub
Different method,
Sub test2()
Dim ws1 As Worksheet, ws2 As Worksheet, txt As String, temp As String
Dim e, x, LR, a(1), n As Long
Set ws1 = Sheets("Sheet1"): Set ws2 = Sheets("Sheet2")
txt = "match(ws1a1:aLR1&ws1b1:bLR1&ws1c1:cLR1,ws2a1:aLR2&ws2b1:bLR2&ws2c1:cLR1,0)"
For Each e In Array(Array(ws1, ws2), Array(ws2, ws1))
LR = e(0).[a1].CurrentRegion.Rows.Count
temp = txt
temp = Replace( Replace( temp, "ws1", "'" & e(0).Name & "'!"), "ws2", "'" & e(1).Name & "'!")
temp = Replace( Replace( temp, "LR1", LR), "LR2", e(1).[a1].CurrentRegion.Rows.Count)
x = Filter(Evaluate("transpose(if(iserror(" & temp & "),row('" & e(0).Name & "'!a1:a" & LR & ")))"), False, 0)
a(n) = x: n = n + 1
Next
With ws2
If UBound(a(0)) > -1 Then
.Cells(n - 1, "f").Resize(UBound(a(0)) + 1, 3) = Application.Index(ws1 _
.[a1].CurrentRegion.Value, .Application.Transpose(a(0)), Array(1, 2, 3))
n = n + UBound(a(0)) + 1
End If
If UBound(a(1)) > -1 Then
.Cells(n - 1, "f").Resize(UBound(a(1)) + 1, 3) = Application.Index(ws2 _
.[a1].CurrentRegion.Value, .Application.Transpose(a(1)), Array(1, 2, 3))
End If
.Columns("f").NumberFormat = "0"
End With
End Sub
Bookmarks