|

楼主 |
发表于 2013-4-5 12:41
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
字典嵌套:
Sub test()
Dim arr, i%, j%, d, s, sd$
sd = "scripting.dictionary"
Set d = CreateObject(sd)
arr = [a1].CurrentRegion
For i = 2 To UBound(arr)
For j = 2 To UBound(arr, 2)
If arr(i, j) <> "" Then
If d.exists(arr(i, j)) = 0 Then
Set d(arr(i, j)) = CreateObject(sd)
End If
d(arr(i, j))(arr(i, 1)) = ""
End If
Next j
Next i
[a8].Resize(d.Count) = Application.Transpose(d.keys)
s = d.items
For i = 0 To d.Count - 1
[b8].Offset(i).Resize(1, s(i).Count) = s(i).keys
Next i
End Sub
|
|