Sub qs18()
Dim arr, dic
Set dic = CreateObject("scripting.dictionary")
arr = Sheet4.Range("a1").CurrentRegion.Value
ReDim brr(1 To UBound(arr), 1 To 12)
For i = 2 To UBound(arr)
s = Join(Array(arr(i, 2), arr(i, 30), arr(i, 3), arr(i, 4)))
If Not dic.exists(s) Then
m = m + 1
dic(s) = m
ss = Split(s)
For a = 0 To 3
brr(m, a + 1) = ss(a)
Next
brr(m, 5) = Val(arr(i, 14))
brr(m, 6) = Val(arr(i, 15))
brr(m, 7) = Val(arr(i, 16))
brr(m, 8) = Val(arr(i, 17))
brr(m, 9) = Val(arr(i, 18))
brr(m, 10) = Val(arr(i, 19))
brr(m, 11) = Val(arr(i, 20))
brr(m, 12) = arr(i, 30)
Else
r = dic(s)
brr(r, 5) = brr(r, 5) + Val(arr(i, 14))
brr(r, 6) = brr(r, 6) + Val(arr(i, 15))
brr(r, 7) = brr(r, 7) + Val(arr(i, 16))
brr(r, 8) = brr(r, 8) + Val(arr(i, 17))
brr(r, 9) = brr(r, 9) + Val(arr(i, 18))
brr(r, 10) = brr(r, 10) + Val(arr(i, 19))
brr(r, 11) = brr(r, 11) + Val(arr(i, 20))
End If
Next
Sheet3.Range("a10").Resize(m, 12) = brr
End Sub |