Try this:-
Results start sheet "Result" "A1"
Sub MG15Jan21
Dim Rng1 As Range
Dim Dn As Range
Dim Rng2 As Range
Dim Rng3 As Range
Dim temp As Range
Dim oSet As Long
Dim Ray
Dim Ac As Long
Dim n As Long
Dim Q
Dim A, B, C
Dim P As Long
With Sheets("TBL1")
Set Rng1 = .Range(.Range("B2"), .Range("B" & Rows.Count).End(xlUp))
End With
With Sheets("TBL2")
Set Rng2 = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
End With
With Sheets("TBL3")
Set Rng3 = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
End With
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
Ray = Array(Rng1, Rng2, Rng3)
For Ac = 0 To UBound(Ray)
For Each Dn In Ray(Ac)
Select Case Ac
Case 0: oSet = -1: A = Dn.Offset(, oSet)
Case 1: oSet = 1: B = Dn.Offset(, oSet)
Case 2: oSet = 2: C = Dn.Offset(, oSet)
End Select
Dim t
If Not IsEmpty(Dn) Then Set temp = Dn
If Not .Exists(temp.Value) Then
.Add temp.Value, Array(A, B, C)
Else
Q = .Item(temp.Value)
If Q(Ac) = Empty Then
Q(Ac) = Dn.Offset(, oSet)
Else
Q(Ac) = Q(Ac) & "," & Dn.Offset(, oSet)
End If
.Item(temp.Value) = Q
End If
Next Dn
Next Ac
Dim Sp1 As Variant
Dim Sp2 As Variant
Dim Sp3 As Variant
Dim n1 As Long
Dim n2 As Long
Dim n3 As Long
Dim K
For Each K In .keys
Sp1 = Split(.Item(K)(0), ",")
Sp2 = Split(.Item(K)(1), ",")
Sp3 = Split(.Item(K)(2), ",")
For n1 = 0 To UBound(Sp1)
For n2 = 0 To UBound(Sp2)
For n3 = 0 To UBound(Sp3)
P = P + 1
Sheets("Result").Cells(P, "A") = Sp1(n1)
Sheets("Result").Cells(P, "B") = Sp2(n2)
Sheets("Result").Cells(P, "C") = Sp3(n3)
Next n3
Next n2
Next n1
Next K
End With
End Sub
Regards Mick
Bookmarks