If Statement help, please

  • Thread starter Thread starter Ross
  • Start date Start date
R

Ross

Hi all

I have what seemed to me to be a simple task: If both A1 and
B1 have nothing in them, show nothing, but if either cell has something in
it, do the math...A1+B1. So I wrote: if(A1+B1="","",A1+B1). Unfortunately,
it'll do the math, but it shows a zero for the rows that have no input. Can
someone help?? And explain why??

Thanks very much
 
I'd use:
=if(count(a1,b1)=2,a1+b1,"")


Hi all

I have what seemed to me to be a simple task: If both A1 and
B1 have nothing in them, show nothing, but if either cell has something in
it, do the math...A1+B1. So I wrote: if(A1+B1="","",A1+B1). Unfortunately,
it'll do the math, but it shows a zero for the rows that have no input. Can
someone help?? And explain why??

Thanks very much
 
Well, you're right. It certainly did do the trick. And thanks for
explaining it. There's no way I would get as good an explaination from the
Help menu!
--
smither fan


David Biddulph said:
Well, you'd already demonstrated that A1+B1 was doing the arithmetic and
being calculated as zero, so when you compared it with the empty string ""
it failed the test. [You can check the result of the comparison and see
that =(0="") returns FALSE.]
If you wanted to use the string comparison, you could have used as the input
the result of a string concatenation instead of an arithmetic addition, and
hence you could have used =IF(A1&B1="","",A1+B1)
That, however, still wouldn't have worked if one or both of your input cells
had not been empty but, for example, contained a space " ", so the COUNT
recommendation is a better bet.
--
David Biddulph

Ross said:
Thanks Dave. Can you please tell me why my original one didn't work?
 

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

Similar Threads


Back
Top