'假设A列有序
Option Explicit
Sub abc()
Dim a, i, m, n
a = [a1].CurrentRegion.Offset(1).Value
ReDim b(1 To UBound(a), 20) '输出最多支持20列,自己修改
m = 1: n = 0
For i = 1 To UBound(a) - 1
n = n + 1
b(m, n) = a(i, 2)
If a(i, 1) <> a(i + 1, 1) Then _
b(m, 0) = a(i, 1): m = m + 1: n = 0
Next
[d2].Resize(m, UBound(b, 2) + 1) = b
End Sub