Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 102
Default combine IF, AND and OR operstors in a statement

How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default combine IF, AND and OR operstors in a statement

I just tested this and it worked as advertised when i24 contained ? and i16
either y or ?
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","MM")

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Vince" wrote in message
...
How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,059
Default combine IF, AND and OR operstors in a statement

On Dec 19, 11:26 am, Vince wrote:
How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error


Do you mean an Excel error message; or do you mean the word "ERROR"?

I do not get any Excel error message when I cut-and-paste what you
wrote above into an Excel spreadsheet. Perhaps you have a typo in
your spreadsheet that you did not repeat when you wrote your posting.
You might try replacing your spreadsheet formula by cut-and-pasting
from your posting, as I did.

If you mean you got the word "ERROR", of course there could be an
error in your logic. To determine that, I would need to know what
values you have in I16 and I24 or a precise specification of your
expectations for all combination of the contents of I16 and I24.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default combine IF, AND and OR operstors in a statement

It's kind of confusing to know what you mean when you said ""creates an
error" given that if the logical test is not met, you return the word
"ERROR". Anyway, I tried your code and it does what it says... if I16 has
either a "Y" or "?" in it AND if I24 has a "?", then "Please enter country
code" is display; if either of those cells contain anything else, the word
"ERROR" is returned... the code does work and no worksheet errors are
generated. What is it you thought should happen that prompted you to post
your question?

Rick


"Vince" wrote in message
...
How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default combine IF, AND and OR operstors in a statement

What error

the formula says if (I16=Y or ?) AND I24=? then return 'Please enter country
code'
and if those econditions aren't met return ERROR and that works

What are you expecting to happen?

Mike

"Vince" wrote:

How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 102
Default combine IF, AND and OR operstors in a statement

Thanks - yes it does work - my bloodshot eye focus must have been playing up.
In the office at 7am today and still at the computer at 10.20 ! Sad or what?


"Don Guillett" wrote:

I just tested this and it worked as advertised when i24 contained ? and i16
either y or ?
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","MM")

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Vince" wrote in message
...
How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 102
Default combine IF, AND and OR operstors in a statement

Excel error message. Thanks - yes it does work - my bloodshot eye focus must
have been playing up. In the office at 7am today and still at the computer
at 10.20 ! Sad or what?

"Mike H" wrote:

What error

the formula says if (I16=Y or ?) AND I24=? then return 'Please enter country
code'
and if those econditions aren't met return ERROR and that works

What are you expecting to happen?

Mike

"Vince" wrote:

How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 102
Default combine IF, AND and OR operstors in a statement

Excel error. It does work - my bloodshot eye focus must have been playing
up. In the office at 7am today and still at the computer at 10.20 ! Sad or
what?

"joeu2004" wrote:

On Dec 19, 11:26 am, Vince wrote:
How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error


Do you mean an Excel error message; or do you mean the word "ERROR"?

I do not get any Excel error message when I cut-and-paste what you
wrote above into an Excel spreadsheet. Perhaps you have a typo in
your spreadsheet that you did not repeat when you wrote your posting.
You might try replacing your spreadsheet formula by cut-and-pasting
from your posting, as I did.

If you mean you got the word "ERROR", of course there could be an
error in your logic. To determine that, I would need to know what
values you have in I16 and I24 or a precise specification of your
expectations for all combination of the contents of I16 and I24.


  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 102
Default combine IF, AND and OR operstors in a statement

Sorry - I meant an excel error. It does work - my bloodshot eye focus must
have been playing up. In the office at 7am today and still at the computer
at 10.20 ! Sad or what?

"Rick Rothstein (MVP - VB)" wrote:

It's kind of confusing to know what you mean when you said ""creates an
error" given that if the logical test is not met, you return the word
"ERROR". Anyway, I tried your code and it does what it says... if I16 has
either a "Y" or "?" in it AND if I24 has a "?", then "Please enter country
code" is display; if either of those cells contain anything else, the word
"ERROR" is returned... the code does work and no worksheet errors are
generated. What is it you thought should happen that prompted you to post
your question?

Rick


"Vince" wrote in message
...
How do I nest AND & OR operators in an IF statement? E.g. the statement
=IF(AND(OR(I16="Y",I16="?"),I24="?"),"Please enter country code","ERROR")
creates an error



  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default combine IF, AND and OR operstors in a statement

Sorry - I meant an excel error. It does work - my bloodshot eye focus
must have been playing up.


But, if I understand you correctly, you are not getting an Excel error any
more, right?

In the office at 7am today and still at the computer at 10.20 ! Sad or
what?


Well, if that 10:20 time were in the AM, it wouldn't be that sad; but I am
guessing that is not the case, eh? <g

Rick

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
Can an If statement answer an If statement? M.A.Tyler Excel Discussion (Misc queries) 2 June 24th 07 04:14 AM
HLookup, IF statement, multiple sort, somehow combine all of these Gita at CASTLE Excel Worksheet Functions 0 May 2nd 06 07:43 PM
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 04:54 AM.

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"