|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
大师好!如果是字典需要提取多列数据,以下代码该如何写?- Sub csm()
- Dim i&, d(1 To 3), arr, brr, j&
- tt = Timer
- For i = 1 To UBound(d)
- Set d(i) = CreateObject("scripting.dictionary")
- Next
- arr = Sheet1.UsedRange.Value
- For i = 2 To UBound(arr, 1)
- 'brr = Array(arr(i, 4), arr(i, 5), arr(i, 9), arr(i, 10), arr(i, 11), arr(i, 12), arr(i, 13), arr(i, 14), arr(i, 15), arr(i, 16))
- brr = arr(i, 4)
- d(1)(arr(i, 3)) = brr
- d(2)(arr(i, 24)) = arr(i, 24)
- 'd(3)(arr(i, 3) & arr(i, 24)) = d(3)(arr(i, 3) & arr(i, 24)) + arr(i, 26)
- Next
- With Sheets("透视汇总")
- .UsedRange.Cells.ClearContents
- For j = 0 To UBound(brr)
- .[a2].Resize(d(1).Count, j + 1) = Application.Transpose(Array(d(1).Keys, d(1)(j).Items))
- Next
- End With
- Application.ScreenUpdating = True
- MsgBox "计算完毕,共用时" & Format(Timer - tt, "00") & "秒!"
- End Sub
复制代码
|
|