Sub Demo1()
Dim F$, S$, V, R&, L&, W, C%
Application.ScreenUpdating = False
[J1].CurrentRegion.Clear
With [A1].CurrentRegion.Columns
.Item("A:B").AdvancedFilter 2, , [J1], True
F = .Item(1).Address(, , xlR1C1) & ",RC10," & .Item(2).Address(, , xlR1C1) & ",RC[-"
S = "=SUMIFS(" & .Item(6).Address(, , xlR1C1) & "," & F & "1])"
F = "=COUNTIFS(" & F & "2])"
End With
With [J1].CurrentRegion.Rows
If .Count = 1 Then Beep: Exit Sub
.Sort .Cells(1), 1, Header:=1
V = .Value2
.Item("2:" & .Count).Clear
End With
R = 1
For L = 2 To UBound(V)
If V(L, 1) = W Then C = C + 3 Else C = 11: R = R + 1: W = V(L, 1): Cells(R, 10).Value2 = W
Cells(R, C).Resize(, 3).Formula = Array(V(L, 2), S, F)
Next
With [J1].CurrentRegion.Columns
.Range("B1:D1").Value2 = [{"Order #1","Amount #1","Count #1"}]
If .Count > 4 Then .Range("B1:D1").AutoFill .Cells(2).Resize(, .Count - 1)
End With
Application.ScreenUpdating = True
End Sub