答案 0 :(得分:1)
可能的变体之一:
Sub test()
Dim Dic As Object: Set Dic = CreateObject("Scripting.Dictionary")
Dim x&, Z%, cl As Range
x = Cells(Rows.Count, "A").End(xlUp).Row
Debug.Print (TypeName(Z))
For Each cl In Range("A2:A" & x)
append = cl.Offset(, 1) & "|" & cl.Offset(, 2) & "|" & cl.Offset(, 3)
If Not Dic.exists(UCase(cl.Value2)) Then
Dic.Add UCase(cl.Value2), append
Else
Dic(UCase(cl.Value2)) = Dic(UCase(cl.Value2)) & "|" & append
End If
Next cl
Workbooks.Add
x = 2
For Each d In Dic
Z = UBound(Split(Dic(d), "|")) + 1
Cells(x, "A") = d: Cells(x, "B").Resize(, Z) = Split(Dic(d), "|")
x = x + 1
Next d
End Sub
试验:
源:
结果:
答案 1 :(得分:1)