Michael M
Well-known Member
- Joined
- Oct 27, 2005
- Messages
- 21,865
- Office Version
- 365
- 2019
- 2013
- 2007
- Platform
- Windows
Hi All
I've been trying to improve my knowledge of Dictionaries and have been using this code kindly submitted by @Rick Rothstein some time ago.
How can I expand the data so that it also sums column "C" as well. Any help would be much appreciated
I've been trying to improve my knowledge of Dictionaries and have been using this code kindly submitted by @Rick Rothstein some time ago.
How can I expand the data so that it also sums column "C" as well. Any help would be much appreciated
VBA Code:
Sub Consolidate()
Dim R As Long, Data As Variant
Data = Range("A2", Cells(Rows.Count, "B").End(xlUp))
With CreateObject("Scripting.Dictionary")
For R = 1 To UBound(Data)
.Item(Data(R, 1)) = .Item(Data(R, 1)) + Data(R, 2)
Next R
Range("D2").Resize(.Count) = Application.Transpose(.Keys)
Range("E2").Resize(.Count) = Application.Transpose(.Items)
End With
End Sub