|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
哪位大神能帮忙逐句解释一下,这个语法写的跟我的要求不一样但不知道哪里出现了问题
Sub AwTest()
Dim i%, j%, iStr$, arr, brr, d As Object
Set d = CreateObject("Scripting.Dictionary")
With Sheets("原始数据")
arr = .[a1].CurrentRegion
For i = 4 To UBound(arr)
If Len(arr(i, 1)) Then
iStr = ""
For j = 2 To 7
iStr = iStr & "|" & arr(i, j)
Next
If Not d.exists(iStr) Then
d(iStr) = ""
d(iStr & "|" & "Cnt") = 1
d(iStr & "|" & "Sum") = arr(i, 12)
d(iStr & "|" & "Max") = arr(i, 13)
d(iStr & "|" & "Min") = arr(i, 12)
For j = 8 To 11
d(iStr & "|" & arr(3, j)) = arr(i, j)
Next
Else
d(iStr & "|" & "Cnt") = d(iStr & "|" & "Cnt") + 1
d(iStr & "|" & "Sum") = d(iStr & "|" & "Sum") + arr(i, 12)
If arr(i, 12) > d(iStr & "|" & "Max") Then d(iStr & "|" & "Max") = arr(i, 12)
If arr(i, 12) < d(iStr & "|" & "Min") Then d(iStr & "|" & "Min") = arr(i, 12)
End If
End If
Next
End With
With Sheets("查询页面")
arr = .[a1].CurrentRegion
iStr = ""
For j = 1 To 6
iStr = iStr & "|" & arr(4, j)
Next
.[a11:m13] = ""
brr = .[a8:m13]
For i = 4 To UBound(brr)
For j = 1 To UBound(brr, 2) - 7
brr(i, j) = arr(4, j)
Next
For j = 7 To 10
If d.exists(iStr & "|" & brr(3, j)) Then brr(i, j) = d(iStr & "|" & brr(3, j))
Next
Next
brr(4, 11) = Round(d(iStr & "|" & "Sum") / d(iStr & "|" & "Cnt"), 1)
brr(5, 11) = d(iStr & "|" & "Max")
brr(6, 11) = d(iStr & "|" & "Min")
.[a8:m13] = brr
End With
End Sub
|
|