If with Or & And

Kathryn2

New Member
Joined
Aug 28, 2009
Messages
4
I have multiple conditions for Or and And that need to be in an If statement. How do I write the IF statement?

Thanks in advance!

Conditions:
If A or B is no, then no
If A or B is maybe, then maybe
If A or B is NA, then take the other cell

Else, Yes

A
B
Should answer
1
Yes
Yes
Yes
2
Maybe
Yes
Maybe
3
No
Maybe
No
4
NA
Yes
Yes

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
how about this:

=IF(OR(A="No",B="No"),"No",IF(OR(A="Maybe",B="Maybe"),"Maybe",IF(A="NA",B,IF(B="NA",A,"Yes"))))

so what happens if both are NA?

Edit: actually, I just noticed that there are conflicting things...

What happens if one is "No" and the other is "Maybe?" You say if either is a No, then No, and if either is a Maybe then Maybe...
 
Upvote 0
how about this:

=IF(OR(A="No",B="No"),"No",IF(OR(A="Maybe",B="Maybe"),"Maybe",IF(A="NA",B,IF(B="NA",A,"Yes"))))

so what happens if both are NA?

Edit: actually, I just noticed that there are conflicting things...

What happens if one is "No" and the other is "Maybe?" You say if either is a No, then No, and if either is a Maybe then Maybe...

----
Sorry,

If one is "No" and the other is maybe, then it's "No" (No overrides them all)
Both will never be NA

Thanks!
 
Upvote 0
i came up with this.. but there is conflict with the "maybe' and the NO..

Sheet2

ABCDE
1ABShould answer
2YesYesYes yes
3MaybeYesMaybe maybe
4NoMaybeNo maybe
5NAYesYes Yes

<colgroup><col style="width: 30px; font-weight: bold;"><col style="width: 64px;"><col style="width: 64px;"><col style="width: 64px;"><col style="width: 64px;"><col style="width: 64px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
E2=IF(A2="","",IF(A2=B2,"yes",IF(OR(A2="maybe",B2="maybe"),"maybe",IF(OR(A2="no",B2="no"),"no",IF(A2="na",B2,IF(B2="na",A2,""))))))
E3=IF(A3="","",IF(A3=B3,"yes",IF(OR(A3="maybe",B3="maybe"),"maybe",IF(OR(A3="no",B3="no"),"no",IF(A3="na",B3,IF(B3="na",A3,""))))))
E4=IF(A4="","",IF(A4=B4,"yes",IF(OR(A4="maybe",B4="maybe"),"maybe",IF(OR(A4="no",B4="no"),"no",IF(A4="na",B4,IF(B4="na",A4,""))))))
E5=IF(A5="","",IF(A5=B5,"yes",IF(OR(A5="maybe",B5="maybe"),"maybe",IF(OR(A5="no",B5="no"),"no",IF(A5="na",B5,IF(B5="na",A5,""))))))

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4
 
Upvote 0
how about this:

=IF(OR(A="No",B="No"),"No",IF(OR(A="Maybe",B="Maybe"),"Maybe",IF(A="NA",B,IF(B="NA",A,"Yes"))))

so what happens if both are NA?

Edit: actually, I just noticed that there are conflicting things...

What happens if one is "No" and the other is "Maybe?" You say if either is a No, then No, and if either is a Maybe then Maybe...

I hope this solves your problem

=IF(OR(A1="no",B1="no"),"no",IF(OR(A1="maybe",B1="maybe"),"maybe",IF(OR(A1="yes",B1="yes"),"yes","")))
 
Upvote 0
Hi LXQ,

I feel that my solution would be appropriate, since if works in the priority basis. So i have placed no as highest priority, then may be, then yes.
Correct me if i am wrong.

Thanks!
 
Upvote 0
PS - I had to change the Yes part of the formula to the same format as the others because the "IF(A2=B2,"yes"," was returning yes for ones that had "maybe" and "maybe". thanks again!
 
Upvote 0
Hi LXQ,

I feel that my solution would be appropriate, since if works in the priority basis. So i have placed no as highest priority, then may be, then yes.
Correct me if i am wrong.

Thanks!

I guess it's whatever Kathryn wants... I tested your formula and it works, the only difference from mine is how it handles empty cells.. Yours has no coding for "NA" and mine has no coding for empty cells, so it depends on where NA comes from and whether empty cells can be part of this table.. For the "yes," "no," and "maybe" entries, which is what I think Kathryn is interested in, both of our formulas do the job...
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top