ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   combine IF, AND and OR operstors in a statement (https://www.excelbanter.com/excel-worksheet-functions/170304-combine-if-operstors-statement.html)

Vince

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

Don Guillett

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



joeu2004

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.


Rick Rothstein \(MVP - VB\)

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



Mike H

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


Vince

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




Vince

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


Vince

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.



Vince

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




Don Guillett

combine IF, AND and OR operstors in a statement
 

Take the rest of the day off.
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Vince" wrote in 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?


"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





Rick Rothstein \(MVP - VB\)

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



All times are GMT +1. The time now is 06:44 PM.

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