|
用条件再来一个
Sub dd()
Dim d As New Dictionary
Dim J As Long
Dim I As Long
Dim X As Long
Dim ARR
For I = 2 To 111
For J = 2 To 6
If Cells(I, 2) = Cells(J, 5) Then
d((VBA.Month(Cells(I, 1)) & "月") & "|" & Cells(I, 2)) = d((VBA.Month(Cells(I, 1)) & "月") & "|" & Cells(I, 2)) + Cells(I, 3) * Cells(J, 6)
End If
Next
Next
ReDim ARR(d.Count - 1, 1 To 3)
For X = 0 To d.Count - 1
ARR(X, 1) = Split(d.Keys(X), "|")(0)
ARR(X, 2) = Split(d.Keys(X), "|")(1)
ARR(X, 3) = d.Items(X)
Next
Range("h2").Resize(d.Count, 3) = ARR
End Sub
|
|