Sum column B if Column A is the same?

natural1

New Member
Joined
Oct 16, 2009
Messages
4
A B
10 135
10 19
10 15
10 16
11 27
11 19
11 230
11 152
11 37
12 56
12 99​

What I am trying to do is add all the numbers in column B if the numbers in column A are the same. For example A1 to A4 are the same so I want to add B1to B4. A5 to A9 are the same so I want to add B5 to B9, etc. My first time to this forum, so I hope I explained this properly. Please let me know if you need more information. Thank you​
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Like so, enter the values you want to "sum by" and then the formula shown in the adjacent cell:

Excel Workbook
ABCDE
1IDsValuesIDTotal
21013510185
3101911465
4101512155
51016
61127
71119
811230
911152
101137
111256
121299
Sheet4
 
Upvote 0
Thanks for the quick response. I need to explain further, my fault. The numbers in column A will always be changing and my spreadsheets will very from about 50 rows to 300 rows. I need a formula to figure out what cells or values to sum by and a formula to sum Column B accordingly.
 
Upvote 0
Try this. The formula in D2 is different from the one in D3. The D3 formula is an ARRAY formula, you must press CTRL-SHIFT-ENTER to confirm it, then copy the D3 formula down as far as you'd like, it will show 0 when it runs out of values.

Copy the E2 formula down the column E.

You can suppress the zeros by clicking on Tools > Options > View > [ ] Zero Values and uncheck that option for this sheet.

Excel Workbook
ABCDE
1IDsValuesIDsTotal
21013510185
3101911465
4101512155
5101600
6112700
7111900
81123000
91115200
10113700
11125600
12129900
Sheet4
 
Upvote 0
natural1

Welcome to the MrExcel board!

Excel has a couple of built-in features that relate to what you seem to want. Post back if either of these seems like it might be of use and you need more help.


1. Subtotals (Found in the Data menu/ribbon)

Excel Workbook
AB
1IDsValues
210135
31019
41015
51016
610 Total185
71127
81119
911230
1011152
111137
1211 Total465
131256
141299
1512 Total155
16Grand Total805
Subtotals



2. PivotTable (found in Data menu pre 2007 or Insert ribbon 2007)

Excel Workbook
ABCDEF
1IDsValuesSum of Values
210135IDsTotal
3101910185
4101511465
5101612155
61127Grand Total805
71119
811230
911152
101137
111256
121299
13
PivotTable
 
Upvote 0
Mr. Rocket Scientist, Thank you so very much. The formulas work just fine. I definately took a wrong turn when I was working on this. I will have to go through your formula a bit to understand how it all works. Thanks again for your quick response and solutions.
 
Upvote 0
Glad to help.

Peter is right about the pivot tables being cool and worth looking into. I don't use them as much as I should, mostly cause of the extra hoops you have to go through to get them to update each time the data updates. As I said, I don't use them a lot, perhaps there is an easy way to get that, too.
 
Upvote 0
Peter, I just tried PivotTable and Subtotals for the first time (ever). They both work fine. I think Pivot table works best of the two for my current needs. I now have 3 possible ways of doing this, so I will play around with them all and see what happens. Thank you both, jbeaucaire and Peter, for your help and quick responses.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top