ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If Statement help, please (https://www.excelbanter.com/excel-discussion-misc-queries/214662-if-statement-help-please.html)

Ross

If Statement help, please
 
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
--
smither fan

Dave Peterson

If Statement help, please
 
I'd use:
=if(count(a1,b1)=2,a1+b1,"")



Ross wrote:

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
--
smither fan


--

Dave Peterson

Ross

If Statement help, please
 
Thanks Dave. Can you please tell me why my original one didn't work?
--
smither fan


"Dave Peterson" wrote:

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



Ross wrote:

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
--
smither fan


--

Dave Peterson


David Biddulph[_2_]

If Statement help, please
 
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" wrote in message
...
Thanks Dave. Can you please tell me why my original one didn't work?


"Dave Peterson" wrote:

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


Ross wrote:

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??




Ross

If Statement help, please
 
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" wrote:

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" wrote in message
...
Thanks Dave. Can you please tell me why my original one didn't work?


"Dave Peterson" wrote:

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


Ross wrote:

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??






All times are GMT +1. The time now is 02:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com