combine IF, AND and OR operstors in a statement

V

Vince

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
 
D

Don Guillett

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")
 
J

joeu2004

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.
 
R

Rick Rothstein \(MVP - VB\)

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
 
M

Mike H

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
 
V

Vince

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

Vince

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

Vince

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

Vince

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

Rick Rothstein \(MVP - VB\)

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
 
Top