|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub a2()
- Dim d, brr(), i&, m&, n&
- Set d = CreateObject("scripting.dictionary")
- arr = [A1:B10]
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
- d(arr(i, 1))(arr(i, 2)) = ""
- Next
- t = d.keys
- For m = 0 To d.Count - 1
- a1 = d(t(m)).keys
- s = ""
- For n = 0 To UBound(a1)
- s = s & "," & a1(n)
- Next n
- ReDim Preserve brr(1 To m + 1)
- brr(m + 1) = Mid(s, 2)
- Next m
- [C1].Resize(d.Count, 1) = Application.WorksheetFunction.Transpose(d.keys)
- [D1].Resize(d.Count, 1) = Application.WorksheetFunction.Transpose(brr)
- Set d = Nothing: Erase brr
- End Sub
- 可以使用两个字典或者是字典嵌套,仅供参考
复制代码 |
评分
-
1
查看全部评分
-
|