Sub TEST1()
Dim k As Integer, i As Integer
Dim dic As Object
Dim ar, br()
k = 0
Set dic = CreateObject("Scripting.Dictionary")
ar = [A1].CurrentRegion
For i = 3 To UBound(ar) - 1
If dic.Exists(ar(i, 3)) Then
br(3, dic(ar(i, 3))) = br(3, dic(ar(i, 3))) & vbLf & ar(i, 2) & ar(i, 4)
br(2, dic(ar(i, 3))) = br(2, dic(ar(i, 3))) + ar(i, 5)
Else
ReDim Preserve br(1 To 3, 1 To k + 1)
dic(ar(i, 3)) = k + 1
br(1, k + 1) = ar(i, 3)
br(3, k + 1) = ar(i, 2) & ar(i, 4)
br(2, k + 1) = ar(i, 5)
k = k + 1
End If
Next
[G3].Resize(dic.Count, 3) = Application.Transpose(br)
Set dic = Nothing
End Sub
|