Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
I have a table in the following range:
Having column A as a reference point (it is a list of cities), if the same city is repeated, I've to sum all the value in column in order to produce only a row for any city.
Then overwrite the table.
Anyway, at the moment I've figured out only to sum the column B.
How can I expand the same process to all columns until R?
Thank's in advance.
I have a table in the following range:
Code:
Worksheets(1).Range("A2:R" & lr2 + lr3 - 3)
Having column A as a reference point (it is a list of cities), if the same city is repeated, I've to sum all the value in column in order to produce only a row for any city.
Then overwrite the table.
Anyway, at the moment I've figured out only to sum the column B.
Code:
Set Rng = Worksheets(1).Range("A2:R" & lr2 + lr3 - 3)
Set Dic = CreateObject("Scripting.Dictionary")
arr = Rng.Value
For i = 1 To UBound(arr, 1)
Dic(arr(i, 1)) = Dic(arr(i, 1)) + arr(i, 2)
Next
Application.ScreenUpdating = False
Rng.ClearContents
Rng.Range("A1").Resize(Dic.Count, 1) = Application.WorksheetFunction.Transpose(Dic.keys)
Rng.Range("B1").Resize(Dic.Count, 1) = Application.WorksheetFunction.Transpose(Dic.items)
Application.ScreenUpdating = True
How can I expand the same process to all columns until R?
Thank's in advance.
Last edited: