Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summing values in a column 1

Status
Not open for further replies.

Stretchwickster

Programmer
Apr 30, 2001
1,746
GB
I have a 2 columns of data e.g.

id value
1 12
3 34
4 42
2 13
4 45
3 67
1 42

What I want to do is sum all the occurrences of each id so I would get something like:

id total
1 54
2 13
3 101
4 87

I've looked into using VLOOKUP but am sending myself around in circles. Does anyone have any ideas? Clive [infinity]
 
Pivot Table:
select data
goto data>Pivot table
step thru wizard till you get to the arrangement screen
Drag and drop ID into the ROW field
drag and drop TOTAL into the DATA field
Double click on TOTAL and ensure that it is SUM of TOTAL
et voila Rgds
Geoff

Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur
 
In a language you can understand:
Code:
MsgBox "Just the job - Cheers Geoff"
Clive.GiveStar(Geoff)
;-) Clive [infinity]
 
LOL LOL LOL LOL LOL LOL LOL Rgds
Geoff

Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur
 
Ok...I have an extra complication (i.e. 4 columns) now I would like to do the following:

id val id2 val2
3 34 1 43
1 21 4 56
2 6 3 2
4 234 2 123
3 12 5 15

and get as output 2 columns totalling both val and val2:

id val
1 64
2 129
3 48
4 290
5 15

I've tried to use Geoff's process above by selecting the 4 columns of data and dragging id and id2 into ROW and val and val2 into DATA but this method doesn't group the data as above. Anyone any ideas? Clive [infinity]
 
Can you not take columns 3 & 4 and cut and paste underneath cols 1 & 2 - that way it WOULD group
Other than that, you are looking at a pretty tricky bit of code / formulae Rgds
Geoff

Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top