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!
 
(y):ROFLMAO:

I think I should have responded in post 7 to ask OP if CUCxx was a cell reference or not.
Again, I might have just misunderstood OP.
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Oh I see, Excel thinks CUC18 is a cell, but it is actually a text. But it didn't work putting the CUC18 in " ", or separating with"," or with ";". I will give up and just use the array formula. I liked to be able to write the name of the articles, because I don't have to be referencing another table that might change.
 
Upvote 0
No, Excel wouldn't think CUC18 is a cell reference if the formula syntax is correct.
I thought CUC18 was a cell reference, it was my oversight not to have clarified with you regarding same.

So the formula Should work, in the US version of Excel, the syntax would be:

Excel Formula:
=SUM(SUMIF(venta!B:B,{"CUC18","CUC24","CUC30","CUC36","CUC42"},venta!H:H))

But since you're using a Spanish version of Excel, I don't know what needs to be changed,
Fluff gave a suggestion in Post # 13, I assume you've tried it.

I've checked with an online Excel Formula Translator, and it came up with the same as Fluff's suggestion.
 
Upvote 0
Edit: Unless you use separate SUMIF for Each Cell reference, then SUM.

but unless "CUC18","CUC24","CUC30","CUC36","CUC42" are actual Text Values as the SUMIF criteria, it is not a Range of cells reference...and it won't work inside a single SUMIF
Although this is not the correct answer for the thread, a little trick you may not be aware of for using an array of single cells as criteria.

Excel Formula:
=SUM(SUMIF(venta!B:B,CHOOSE({1,2,3,4,5},CUC18,CUC24,CUC30,CUC36,CUC42),venta!H:H))
Or with dynamic arrays, I believe this should work.
Excel Formula:
=SUM(SUMIF(venta!B:B,INDEX(CUC:CUC,SEQUENCE(5,,18,6)),venta!H:H))
 
Upvote 0
No, Excel wouldn't think CUC18 is a cell reference if the formula syntax is correct.
I thought CUC18 was a cell reference, it was my oversight not to have clarified with you regarding same.

So the formula Should work, in the US version of Excel, the syntax would be:

Excel Formula:
=SUM(SUMIF(venta!B:B,{"CUC18","CUC24","CUC30","CUC36","CUC42"},venta!H:H))

But since you're using a Spanish version of Excel, I don't know what needs to be changed,
Fluff gave a suggestion in Post # 13, I assume you've tried it.

I've checked with an online Excel Formula Translator, and it came up with the same as Fluff's suggestion.
I am now unable to do anything as my Excel is crashing with too many formulas :(

But, as last I tested, this is the same way you write it in Spanish and it didn't work. In the end the array formula is the only one I could get to work.

Thanks everybody for the help.
 
Upvote 0
Sorry couldn't help you further, thanks for the feedback.
I wonder if, you using an older version of Excel (2007) has anything to do with it.
 
Upvote 0
With the crash or with the formula not working? Because if you think the crash will improve I will look into updating.
 
Upvote 0
I can't see any reason for the formula not working, or for one version to cause excel to crash, but not the other.

If you have used entire columns with a lot of criteria then that could be 1 reason for it crashing, especially if you have such formulas in multiple cells. Entire columns with SUMIF formulas are ok if used sparingly, but they waste a lot of system resources if you have too many of them, if that is the case then it is better to use dynamic ranges / structured tables.
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

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