Sum cells only if not zero or blank

samir_aguiar

New Member
Joined
May 6, 2011
Messages
16
Hello there,

I searched everywhere and couldn't find what I'm looking for. I have two columns, say A and B and I want to sum the cells of B. I want only to sum the cells where the cell by its side (A cell) is not zero or blank.

How do I do that? I tried SUMIF but couldn't add another condition...

Thanks in advance.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Use SUMPRODUCT instead. Say your range is A2:B20, the formula is:

=SUMPRODUCT(B2:B20,--(A2:A20<>0))

The "double minus" in front of the second term is important, it forces a string of TRUE,FALSE,TRUE,TRUE..... to become ones and zeros.
 
Upvote 0
Thanks a lot, both worked! One question, why I get a 0 when I change the < and > condition in the second one? (from {">0","<0"} to {"<0",">0"})

Edit: instead of =SUM(SUMIF(A:A,{">0","<0"},B:B)) I just used SUMIF(A:A,{">0","<0"},B:B). Any differences?
 
Last edited:
Upvote 0
instead of =SUM(SUMIF(A:A,{">0","<0"},B:B)) I just used SUMIF(A:A,{">0","<0"},B:B). Any differences?

Yes. There is difference. It just SUM the first condition, which is ">0". Will not SUM "<0"

If you just want to SUM >0 numbers, just use

=SUMIF(A:A,">0",B:B)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,719
Members
452,939
Latest member
WCrawford

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