Using sumif to add a series different criteria in the same column.

isafloor

New Member
Joined
Feb 3, 2015
Messages
37
Office Version
  1. 2007
Hello, I saw some similar posts but even though the problem is the same, I don't quite get them.

I have a series of products that I want to add together, and this criteria can change. For example:

ProductSales period 1Sales period 2
Apples105
Pears1
Celery94
Pumpkin52

I would like to add Apples, Pears and Celery, but not Pumpkin. This list has 4 items, but the real one has 50. I'd like to avoid doing a series of sum.if for each individual item, and instead doing something like:

=sum.if(A:A,"apples"or"pears"or"celery", B:B)

It would also be nice to have an option to reference another place that would be great to, for example supposing the list "apples / pears / celery / pumpkin" is in D1:D4:

=sum.if(A:A,D1:D3,B:B)

Are these two options possible somehow?

Thanks!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You need to use
Excel Formula:
=SUM(SUMIF(A:A,D1:D3,B:B))
Which must be array confirmed with Ctrl Shift Enter.
 
Upvote 0
Solution
Great, and is it possible to do it as the first example (manually introduce the names in a string of names)? Something like: =sum.if(A:A,"apples"or"pears"or"celery", B:B)
 
Upvote 0
And another question, each time I modify the formula I will have to enter ctrlshiftenter? Because I am using this formulated sheet to change the name of the excel file with find and replace, as I start getting more recent sales report I would substitute the name of the file in all formulas.
 
Upvote 0
For that you would use an array constant.
Excel Formula:
=SUM(SUMIF(A:A,{"apples","pears","celery"},B:B))
This one does not need array confirming.

Regarding your follow up question, you shouldn't need to array confirm it again if you are using find and replace to edit the formula, but you would need to if you manually edit the formula in the cell.
 
Upvote 0
I can't get the one without array to work, I tried two options, and both won't even let me push "enter", I get an error popup:

SUM(SUM.IF(venta!B:B,(A4,A5,A6,A7,A8),venta!H:H))

SUM(SUM.IF(venta!B:B,("CUC18","CUC24","CUC30","CUC36","CUC42"),venta!H:H))

Any ideas? Column B is the name of the product, and H the sales.

Cheers,
 
Upvote 0
Hi,

You won't be able to use Cell references with the SUM(SUMIF formula, the values Must be "hardcoded" and within curly brackets, not parenthesis.

Edit: Unless you use separate SUMIF for Each Cell reference, then SUM.
 
Upvote 0
You can use a range for the criteria, like Jason did in post#2
 
Upvote 0
Thanks, I didn't notice the curly brackets. I changed it to:

SUM(SUM.IF(venta!B:B,{"CUC18","CUC24","CUC30","CUC36","CUC42"},venta!H:H))

It still won't let me hit "enter" I get the error still.
 
Upvote 0
What language is your version of Excel?
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

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