SUM 2 cells only if there is a value in both

M

milt

I want to SUM two cells in an Excel worksheet but only if there is a value in
both cells. For each month of the year I want to show total minutes (B32:43)
less minutes used (D32:43). The answer will be in (E32:43). However if I use
the simple SUM function =SUM(B32-D32) I get the total minutes in Column E if
there is nothing in column D. I've looked at SUMIF but cannot figure out how
to use it for this purpose. Thanks for your help.
 
M

Mike H

Hi,

You don'r need sum to subtract a number from another, try this

=IF(COUNT(B32,D32)=2,B32-D32,"")


Mike
 
S

smartin

milt said:
I want to SUM two cells in an Excel worksheet but only if there is a value in
both cells. For each month of the year I want to show total minutes (B32:43)
less minutes used (D32:43). The answer will be in (E32:43). However if I use
the simple SUM function =SUM(B32-D32) I get the total minutes in Column E if
there is nothing in column D. I've looked at SUMIF but cannot figure out how
to use it for this purpose. Thanks for your help.

In E32:
=IF(D32="","",B32-D32)

Fill down.
 
D

David Biddulph

To start with, you haven't actually used the SUM function. You have given
the function only one argument, and you haven't given it any other arguments
to sum to the first argument. If you want B32-D32 the formula is =B32-D32,
and it doesn't need the SUM function. [If you want to know how the SUM
function works, look it up in Excel help.]

If you want to calculate this only if there is data in both cells, you can
use =IF(COUNT(B32,D32)=2,B32-D32,"")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top