Now you are asking completely different question.
Sub test()
Dim a, e, s, i As Long, ii As Long, n As Long, x, w, dic As Object
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
With Sheets("report")
a = .Range("a1", .Cells.SpecialCells(11)).Resize(, 15).Value
End With
x = Array(1, 2, 4, 6, 8, 10, 12)
For i = 3 To UBound(a, 1)
If a(i, 14) <> "" Then
If Not dic.exists(a(i, 14)) Then
Set dic(a(i, 14)) = CreateObject("Scripting.Dictionary")
dic(a(i, 14)).CompareMode = 1
End If
If Not dic(a(i, 14)).exists(a(i, 15)) Then
ReDim w(1 To UBound(x) + 1, 1 To 1)
Else
w = dic(a(i, 14))(a(i, 15))
ReDim Preserve w(1 To UBound(w, 1), 1 To UBound(w, 2) + 1)
End If
For ii = 0 To UBound(x): w(ii + 1, UBound(w, 2)) = a(i, x(ii)): Next
dic(a(i, 14))(a(i, 15)) = w
Else: Exit For
End If
Next
With Sheets.Add
For Each e In dic
n = n + 1
With .Cells(n, 1)
.Value = e: .Font.Bold = True
End With
For Each s In dic(e)
n = n + 2: .Cells(n, 1).Value = s
n = n + 1
.Cells(n, 1).Resize(UBound(dic(e)(s), 2), 7).Value = _
Application.Transpose(dic(e)(s))
n = n + UBound(dic(e)(s), 2)
Next
Next
End With
End Sub
Bookmarks