|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按钮1_Click()
Set d = CreateObject("scripting.dictionary")
Set dnm = CreateObject("scripting.dictionary")
arr = [a1].CurrentRegion
ReDim brr(1 To UBound(arr), 1 To UBound(arr) * UBound(arr, 2))
r = 2
c = 1
For j = 2 To UBound(arr)
If Not dnm.exists(arr(j, 1)) Then
r = r + 1
dnm(arr(j, 1)) = r
brr(r, 1) = arr(j, 1)
End If
rx = dnm(arr(j, 1))
If Not d.exists(arr(j, 2)) Then
Set d(arr(j, 2)) = CreateObject("scripting.dictionary")
For i = 3 To UBound(arr, 2)
c = c + 1
brr(1, c) = arr(j, 2)
brr(2, c) = arr(1, i)
d(arr(j, 2))(arr(1, i)) = c
brr(rx, c) = arr(j, i)
Next i
Else
For i = 3 To UBound(arr, 2)
brr(rx, d(arr(j, 2))(arr(1, i))) = Val(brr(rx, d(arr(j, 2))(arr(1, i)))) + Val(arr(j, i))
Next i
End If
Next j
[h10].Resize(r, c) = brr
End Sub
|
|