Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 152
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 152
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default 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??



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 152
Default 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??




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum if statement with a left statement Eric D Excel Discussion (Misc queries) 4 July 23rd 08 05:31 PM
Can an If statement answer an If statement? M.A.Tyler Excel Discussion (Misc queries) 2 June 24th 07 04:14 AM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM
If statement and Isblank statement Rodney C. Excel Worksheet Functions 0 January 18th 05 08:39 PM
Help please, IF statement/SUMIF statement Brad_A Excel Worksheet Functions 23 January 11th 05 02:24 PM


All times are GMT +1. The time now is 01:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"