|
▼assya さん:
γさんの、ここを含む掲示板での回答を見て
わたしも使えるようになった方法です。
空の2次元配列を用意して、
各要素に加算を繰り返すことで集計します。
dictionaryには、配列のindexを登録していす。
Sub test()
Dim dic As Object
Dim w()
Dim r As Long, c As Long
Dim v
Dim s As String
Dim n As Long
Set dic = CreateObject("scripting.dictionary")
v = Range("A1:G9").Value
ReDim w(1 To UBound(v, 1), 1 To UBound(v, 2))
For r = 1 To UBound(v, 1)
s = v(r, 1)
If Not dic.exists(s) Then
dic(s) = dic.Count + 1
w(dic(s), 1) = s
End If
n = dic(s)
For c = 2 To UBound(v, 2)
w(n, c) = w(n, c) + v(r, c) '★ここで加算
Next
Next
Range("A21").Resize(dic.Count, UBound(w, 2)).Value = w
End Sub
|
|