try
Sub test()
Dim a, b(), i As Long, n As Long
Dim AL As Object
Set AL = CreateObject("System.Collections.ArrayList")
a = Sheets("info").Range("a1").CurrentRegion.Value
For i = 1 To UBound(a, 1)
If Not AL.Contains(a(i, 2)) Then AL.Add a(i, 2)
Next
ReDim b(1 To UBound(a, 1), 1 To AL.Count)
n = n + 1
For i = 0 To AL.Count - 1
b(n, i + 1) = AL(i)
Next
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For i = 1 To UBound(a, 1)
If Not .exists(a(i, 1)) Then
n = n + 1
.Item(a(i, 1)) = n
End If
b(.Item(a(i, 1)), AL.IndexOf(a(i, 2), 0) + 1) = a(i, 1)
Next
End With
With Sheets("result").Cells(1).Resize(n, AL.Count)
.CurrentRegion.Clear
.Value = b
End With
Set AL = Nothing
End Sub
Bookmarks