sumif for non-blank, non-contiguous cells

TMLstan

New Member
Joined
Jul 9, 2017
Messages
26
Office Version
  1. 365
Platform
  1. Windows
I am trying to write a formula to total data in column C and column E (C+E) only when C or E have data. In other words, when C and E are blank, i would like the formula to return "-". When C or E have data, including a 0, i would like the formula to add C+E.

My only experience with sumif is for ranges, e.g. contiguous data.

My initial alternative was =if(c8+d8>=0,c8+d8,"-") but, for some reason, that returns a 0 even though c8 and d8 are blank.

I have also tried, =if(c8<>"",c8,"-")+if(e8<>"",e8,"-"). This returns a #VALUE ! error.

Any suggestions?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Code:
=if(or(isblank(c8),isblank(e8)),"-",c8+e8)
 
Upvote 0
Code:
=if(or(isblank(c8),isblank(e8)),"-",c8+e8)

Yes, I can make this work JoeMo.

As I implemented your formula, I found an exception that I had not foreseen when I posted my question. What I was looking for when I posted, was to return "-" for the rows in which there was no data. Your solution solves that. What I discovered is that several of the rows for which I do have data, have data in only one of the Columns (C or E) and a blank in the other.

If there is not another way, I can solve that by requiring the managers to enter either data or a zero on each date (row) they complete. Your formula will correctly process this result. If there is a way to accommodate them leaving one of the columns blank if they have no data while completing the other, that would be even better.

Thanks for your quick response.
 
Upvote 0
If you only want "-" returned when both C8 & E8 are blank, just change OR to AND like this:
Code:
=if(and(isblank(c8),isblank(e8)),"-",c8+e8)
 
Upvote 0
If you only want "-" returned when both C8 & E8 are blank, just change OR to AND like this:
Code:
=if(and(isblank(c8),isblank(e8)),"-",c8+e8)

AMAZING. Why didn't I think of that? :rolleyes:

It may seem easy to you...don't underestimate how much your help is appreciated.

Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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