ARM48
ARM48

Reputation: 13

How to use IF OR & AND in excel formula

I am not a coder, but I'm trying to work on an excel sheet to make things more efficient at work. I have two formulas that I need to combine and I can't figure it out! please help. I am trying to put this on my T2 cell.

This is the first one. I basically want to say if O2, R2, and S2 =yes, OR if Q2, R2, and S2 =yes, then "yes" otherwise leave blank. This is what I figured out and it is working! =IF(OR(AND(O2="YES",R2="YES",S2="YES"),AND(Q2="YES",R2="YES",S2="YES")),"YES"," ")

However, If O2=NO and Q2=NO, then I want it to say No, otherwise leave blank. I have the two separate formulas but can't figure out how to combine. IF(OR(AND(O2="NO", Q2="NO"),"NO", " ")

I was thinking maybe I can do this: =IF(OR(AND(O2="YES",R2="YES",S2="YES"),AND(Q2="YES",R2="YES",S2="YES")),"YES","NO") the only problem with this is that it automatically fills a NO, even if the cells are blank. I want it to skip it if its blank. Link to spreadsheet image below:

Upvotes: 1

Views: 193

Answers (2)

Fleury26
Fleury26

Reputation: 585

Put it in the else

=IF(OR(AND(O2="YES",R2="YES",S2="YES"),AND(Q2="YES",R2="YES",S2="YES"));
"YES",
IF(OR(AND(O2="NO", Q2="NO"),
     "NO",
     " "))

Upvotes: 0

Rob Anthony
Rob Anthony

Reputation: 1813

Test it first, then do the rest of the tests

If (AND(O2="NO",Q2="NO"),"NO",IF(AND(R2="YES", S2="YES",OR(O2="YES",Q2="YES")),"YES",""))

I have also grouped the (R2="YES", S2="YES") as you were checking this twice and you don't need to.

Upvotes: 2

Related Questions