|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Set d = CreateObject("scripting.dictionary")
arr = Sheets("数据1").[a1].CurrentRegion
For i = 2 To UBound(arr)
If Not d.exists(arr(i, 2)) Then Set d(arr(i, 2)) = CreateObject("scripting.dictionary")
If Not d(arr(i, 2)).exists(arr(i, 1)) Then Set d(arr(i, 2))(arr(i, 1)) = CreateObject("scripting.dictionary")
d(arr(i, 2))(arr(i, 1))(arr(i, 3)) = arr(i, 4)
Next
ReDim brr(1 To 100, 1 To 20)
m = 0
j = 0
For Each gc In d.keys()
For Each xh In d(gc).keys()
m = 1
j = Right(xh, 1) * 2
For Each bh In d(gc)(xh).keys
m = m + 1
brr(m, 1) = gc
brr(1, j) = xh
brr(m, j) = bh
'brr(m, j + 1) = d(gc)(xh)(bh)
Next
Next
Next
Sheets("导出分解").[a1].Resize(m, 20) = brr
End Sub
|
|