|
可试用字典:
Sub zz()
Dim arr, brr(), d, dd, t, tt
Set d = CreateObject("scripting.dictionary")
Set dd = CreateObject("scripting.dictionary")
arr = [a1].CurrentRegion
For i = 2 To UBound(arr)
d(arr(i, 1)) = d(arr(i, 1)) & "|" & arr(i, 2)
dd(arr(i, 1)) = dd(arr(i, 1)) + 1
Next
t = d.items
tt = Application.Max(dd.items)
ReDim brr(1 To d.Count, 1 To tt)
For i = 0 To UBound(t)
n = Split(Mid(t(i), 2), "|")
For j = 0 To UBound(n)
brr(i + 1, j + 1) = n(j)
Next
Next
[h5].Resize(d.Count, tt) = brr
[g5].Resize(d.Count, 1) = Application.Transpose(d.keys)
Set d = Nothing
Set dd = Nothing
End Sub
|
|