|
- Option Explicit
- Sub test()
- Dim Dic, arr1, arr2(1 To 10000, 1 To 50), k, x
- Set Dic = CreateObject("Scripting.Dictionary")
- arr1 = Range("A1").CurrentRegion
- For x = 2 To UBound(arr1)
- If Not Dic.exists(arr1(x, 1)) Then
- k = k + 1
- Dic(arr1(x, 1)) = k
- arr2(k, 1) = arr1(x, 1)
- arr2(k, 2) = arr1(x, 2)
- Else
- arr2(Dic(arr1(x, 1)), Application.CountIf(Range("A2:A" & x), arr1(x, 1)) + 1) = arr1(x, 2)
- End If
- Next x
- Range("D1:Z10000").ClearContents
- [D1].Resize(k, 50) = arr2
- End Sub
- Sub 清空()
- Range("D1:Z10000").ClearContents
- End Sub
复制代码 |
|