Sub test()
Dim d1, d2, d3, ar, i&, j&, d1k, d2k, br, s
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
Set d3 = CreateObject("scripting.dictionary")
ar = Sheet1.[a1].CurrentRegion
For i = 2 To UBound(ar)
d1(ar(i, 4) & "|" & ar(i, 5)) = ""
d2(ar(i, 2) & "|" & ar(i, 3)) = ""
d3(ar(i, 4) & ar(i, 5) & ar(i, 2) & ar(i, 3)) = ar(i, 6)
Next i
ReDim br(d1.Count + 2, d2.Count + 2)
d1k = d1.keys
For i = 0 To UBound(d1k)
br(i + 2, 0) = Split(d1k(i), "|")(0)
br(i + 2, 1) = Split(d1k(i), "|")(1)
Next i
d2k = d2.keys
For i = 0 To UBound(d2k)
br(0, i + 2) = Split(d2k(i), "|")(0)
br(1, i + 2) = Split(d2k(i), "|")(1)
Next i
For i = 2 To UBound(br)
For j = 2 To UBound(br, 2)
s = br(i, 0) & br(i, 1) & br(0, j) & br(1, j)
br(i, j) = d3(s)
Next j
Next i
Sheet2.[a2].Resize(UBound(br) + 1, UBound(br, 2) + 1) = br
End Sub
|