|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:c" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- m = 1
- ReDim brr(1 To 2, 1 To m)
- Else
- brr = d(arr(i, 1))
- m = UBound(brr, 2) + 1
- ReDim Preserve brr(1 To 2, 1 To m)
- End If
- brr(1, m) = arr(i, 2)
- brr(2, m) = arr(i, 3)
- d(arr(i, 1)) = brr
- Next
- End With
- For Each aa In d.keys
- brr = d(aa)
- ReDim crr(1 To UBound(brr, 2), 1 To UBound(brr))
- For i = 1 To UBound(brr)
- For j = 1 To UBound(brr, 2)
- crr(j, i) = brr(i, j)
- Next
- Next
- d(aa) = crr
- Next
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|