Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default how to write two criteria in if statement?

Could anyone tell me what went wrong with my if statement below?
Thanks,

IF(OR(N31-N9)=0,N31=" ")," ",N31-N9)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default how to write two criteria in if statement?

"Cindy Wang" wrote:
Could anyone tell me what went wrong with my if
statement below?

[....]
IF(OR(N31-N9)=0,N31=" ")," ",N31-N9)


The correct syntax is:

IF(OR(N31-N9=0,N31=" ")," ",N31-N9)
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default how to write two criteria in if statement?

On May 30, 11:54*am, "joeu2004" wrote:
"Cindy Wang" wrote:
Could anyone tell me what went wrong with my if
statement below?

[....]
IF(OR(N31-N9)=0,N31=" ")," ",N31-N9)


The correct syntax is:

IF(OR(N31-N9=0,N31=" ")," ",N31-N9)

I have a fomrula as below,
=IF((VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$D
$24,4,FALSE))=0,"",VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A
$8:$S$25,9,FALSE)/VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A
$8:$D$24,4,FALSE)) It will retrun empty cell if there is no value.
But in my next calculation, I need to exclude that empty cell out, but
I don't know how to define that empty cell. Anybody now? Thanks,
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default how to write two criteria in if statement?

"Cindy Wang" wrote:
On May 30, 11:54 am, "joeu2004" wrote:
"Cindy Wang" wrote:
IF(OR(N31-N9)=0,N31=" ")," ",N31-N9)


The correct syntax is:
IF(OR(N31-N9=0,N31=" ")," ",N31-N9)


Errata.... That will result in a #VALUE error if N31 is non-numeric. Two
alteratives, whichever you prefer:


IF(OR(N(N31)-N9=0,N31=" ")," ",N31-N9)

or

IF(N31="", "", IF(N31-N9=0, "", N31-N9))


"Cindy Wang" wrote:
I have a fomrula as below,
=IF((VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$D
$24,4,FALSE))=0,"",VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A
$8:$S$25,9,FALSE)/VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A
$8:$D$24,4,FALSE))
It will retrun empty cell if there is no value.
But in my next calculation, I need to exclude that empty
cell out, but I don't know how to define that empty cell.


Funny: I was going to comment on your use of " " (one space) instead of ""
(null string) in the formula above. But I chose not to "complicate"
matters.

Anyway, the formula above returns a null string (""), not an "empty cell".
(An "empty cell" is a cell with no formula and no constant; literally
empty.)

So perhaps you want:

IF(OR(N(N31)-N9=0,N31=""),"",N31-N9)

N31="" is TRUE if N31 is empty or it contains the null string (""),
presumably returned from the VLOOKUP formula.

FYI, your VLOOKUP formula is incorrect. It will return an Excel #N/A error
if no match is found.

If you have Excel 2007 or later, you can write:

=IFERROR(VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$S$25,9,FALSE)
/ VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$D$24,4,FALSE), "")

If have Excel 2003 or earlier (or you save to a xls file), you might write:

=IF(ISNUMBER(MATCH(M27,'[Sales Workpaper
2012.xls]May-12'!$A$8:$A$24,0))=FALSE,
"", VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$S$25,9,FALSE)
/ VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$D$24,4,FALSE))

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default how to write two criteria in if statement?

On May 30, 2:59*pm, "joeu2004" wrote:
"Cindy Wang" wrote:
On May 30, 11:54 am, "joeu2004" wrote:
"Cindy Wang" wrote:
IF(OR(N31-N9)=0,N31=" ")," ",N31-N9)


The correct syntax is:
IF(OR(N31-N9=0,N31=" ")," ",N31-N9)


Errata.... *That will result in a #VALUE error if N31 is non-numeric. *Two
alteratives, whichever you prefer:

IF(OR(N(N31)-N9=0,N31=" ")," ",N31-N9)

or

IF(N31="", "", IF(N31-N9=0, "", N31-N9))

"Cindy Wang" wrote:
I have a fomrula as below,
=IF((VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$D
$24,4,FALSE))=0,"",VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A
$8:$S$25,9,FALSE)/VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A
$8:$D$24,4,FALSE))
It will retrun empty cell if there is no value.
But in my next calculation, I need to exclude that empty
cell out, but I don't know how to define that empty cell.


Funny: *I was going to comment on your use of " " (one space) instead of ""
(null string) in the formula above. *But I chose not to "complicate"
matters.

Anyway, the formula above returns a null string (""), not an "empty cell"..
(An "empty cell" is a cell with no formula and no constant; literally
empty.)

So perhaps you want:

IF(OR(N(N31)-N9=0,N31=""),"",N31-N9)

N31="" is TRUE if N31 is empty or it contains the null string (""),
presumably returned from the VLOOKUP formula.

FYI, your VLOOKUP formula is incorrect. *It will return an Excel #N/A error
if no match is found.

If you have Excel 2007 or later, you can write:

=IFERROR(VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$S$25,9,FALSE)
/ VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$D$24,4,FALSE), "")

If have Excel 2003 or earlier (or you save to a xls file), you might write:

=IF(ISNUMBER(MATCH(M27,'[Sales Workpaper
2012.xls]May-12'!$A$8:$A$24,0))=FALSE,
"", VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$S$25,9,FALSE)
/ VLOOKUP(M27,'[Sales Workpaper 2012.xls]May-12'!$A$8:$D$24,4,FALSE))


It looks great, but could you explain to me the first one "OR(N(N31",
what this part does? Thanks,


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default how to write two criteria in if statement?

"Cindy Wang" wrote:
It looks great, but could you explain to me the
first one "OR(N(N31", what this part does?


Sorry, my oversight. It is difficult to find the Help page for the N()
function.

N(N31) returns zero if N31 is text (like the null string ""); otherwise, N31
returns the numeric value of N31 if it is numeric.

N(N31) is equivalent to: IF(ISTEXT(N31),0,N31)

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
better way to write a count if statement? luscioussarita Excel Worksheet Functions 3 March 27th 08 08:32 PM
How do I write a compound if statement? Diane Excel Worksheet Functions 5 May 17th 07 08:52 PM
Hello I am trying to write an If/Then statement. Here is the data. jdamron Excel Programming 2 June 9th 06 12:41 AM
how do I write the date in an if statement Susan Hayes Excel Worksheet Functions 1 August 23rd 05 09:29 PM
How to write a statement about if then Baffle, Atlanta, Ga Excel Programming 2 May 19th 05 07:20 AM


All times are GMT +1. The time now is 02:23 PM.

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

About Us

"It's about Microsoft Excel"