# AND/OR FUNCTION

Ian Bell used Ask the Experts™
on
Hi,
LOGIC
IF A1 = abcd  AND B1 = blue  then 99
OR
IF A1 = abcd AND B2 = yellow then 99
otherwise zero
Many thanks
Ian
Comment
Watch Question

Do more with

EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
=if(and(A1="abcd",or(b1="blue",b2="yellow")),99,0)
retired

Commented:
Thanks Saqib
If I wanted to return 99 if A1 =abcd and B1 <> blue  OR   B1 <> yellow
how would the formula look ?
* no B2 cell this time.

Commented:
Just change b2 to b1

=if(and(A1="abcd",or(b1="blue",b1="yellow")),99,0)
retired

Commented:
I was wanting it to return 99 only if b1 did not contain "blue" or "yellow" and zero if contained blue or yellow........ A1 should always be abcd
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015
Commented:
Hi Ian,

Maybe you need this...

``````=IF(AND(A1="abcd",B1<>"blue",B1<>"yellow"),99,0)
``````
retired

Commented:
I did change the question from = to <> so apologies for that.
Thanks to both of you.
Ian
retired

Commented:
I was trying to place the OR function and that is where I got into a mess.
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
You're welcome Ian. Glad it worked as desired in the end. :)

Do more with

Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.