For i = LBound(ar) To UBound(ar)
If Not d.exists(ar(i)(0)) Then
d(ar(i)(0)) = ar(i)
Else
a = d(ar(i)(0))
a(3) = a(3) + ar(i)(3)
a(4) = a(4) + ar(i)(4)
d(ar(i)(0)) = a
End If
Next
[a1].Resize(7, 5) = Application.Transpose(Application.Transpose(ar))
[a9].Resize(d.Count, 5) = Application.Transpose(Application.Transpose(d.Items))
End Sub
Sub ex2()
Set d = CreateObject("Scripting.Dictionary")
ar = [A1:E7]
For i = LBound(ar) To UBound(ar)
If Not d.exists(ar(i, 1)) Then
d(ar(i, 1)) = Array(ar(i, 1), ar(i, 2), ar(i, 3), ar(i, 4), ar(i, 5))
Else
a = d(ar(i, 1))
a(3) = a(3) + ar(i, 4)
a(4) = a(4) + ar(i, 5)
d(ar(i, 1)) = a
End If
Next
' [a1].Resize(7, 5) = Application.Transpose(Application.Transpose(ar))
[a13].Resize(d.Count, 5) = Application.Transpose(Application.Transpose(d.Items))
End Sub作者: 准提部林 時間: 2016-3-16 11:02
本帖最後由 准提部林 於 2016-3-16 11:04 編輯
多條件統計, 可用 字典檔+陣列,
不過哪幾個條件要說清楚,
yn2 如果有y 及 n, 是否視為不同條件?