Option Explicit
Sub TEST6()
Dim ar, br, i&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = [A1].CurrentRegion.Value
For i = 2 To UBound(ar)
If Not dic.exists(ar(i, 2)) Then
dic(ar(i, 2)) = Array(ar(i, 2), ar(i, 3), ar(i, 4), 1)
Else
br = dic(ar(i, 2))
br(1) = br(1) & "," & ar(i, 3)
br(2) = br(2) + ar(i, 4)
br(3) = br(3) + 1
dic(ar(i, 2)) = br
End If
Next i
[M2].CurrentRegion.Offset(1).Clear
[M3].Resize(dic.Count, 4) = Application.Rept(dic.items, 1)
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|