show blank cell when adding non consecutive cells that are blank ("")

I have a table where I want to add some non consecutive cells. However, if all the cells are blank ("" due to the formulas in these cells), I want the result to be blank ("").
The only thing I've come up with so far is:
=IF((L4="")*(N4=""),"",SUM(L4,N4))
But, this will get a bit cumbersome when there are many cells to add up.

The only other thing I might be able to take advantage of, is the fact that adjacent cells will always be blank (""), although, they will not be summed. (in the above example, M4 and O4 would be blank if their counter parts, L4 and N4, are blank too, it's just I don't want them summed with L4 and N4.

thanks
avoorheisAsked:
Who is Participating?
 
nutschConnect With a Mentor Commented:
You could use

=IF(COUNTIF(L4:O4,"")>2,"",SUM(L4,N4))

0
 
zorvek (Kevin Jones)ConsultantCommented:
The SUM function ignores blank cells even if they are generated with formulas so that will not be an issue.

Using adjacent cells to determine whether or not a cell is blank is smart. I do it all the time to simplify formulas.

Kevin
0
 
nutschCommented:
If you want the result to show as "" instead of 0, you can use a custom format to that end, e.g. 0;-0;


Thomas
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
avoorheisAuthor Commented:
if I use the sum function and sum 2 cells that both = "", then the result is 0. If I sum 2 cells and one is 0 and one is "", then I want the result to be 0.
Maybe I'm stuck with my original thought?
0
 
zorvek (Kevin Jones)ConsultantCommented:
You will get 0 in both cases just as you desire.

What is your question?

Kevin
0
 
avoorheisAuthor Commented:
oh, when I say that the cell = "", that from a formula, like =if(a<>b,"",a+c).
0
 
Saqib Husain, SyedConnect With a Mentor EngineerCommented:
Try this formula

=IF(COUNTIF(H2:H16,"")=ROWS(H2:H16),"",SUM(H2:H16))
0
 
avoorheisAuthor Commented:
I like that nutsch.
0
 
Saqib Husain, SyedConnect With a Mentor EngineerCommented:
or if the data is in a row then

=IF(COUNTIF(L4:N4,"")=COLUMNS(L4:N4),"",SUM(L4:N4))

0
 
Harper-ITConnect With a Mentor Commented:
How about this formula:  =IF(AND(L4="",N4=""),"",SUM(L4,N4))
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.