Multiple IF statement

razormb

New Member
Joined
Apr 28, 2014
Messages
11
Hi there,

I have a spreadsheet with 6 columns of data. If any of say A2, B2, C2, D2 or E2 equal y, then the 6th column will be n. However if A2 and B2 and C2 and D2 and E2 ALL equal n then the 6th column will be Y.

I have got the IF statement working for the first section:

=IF(A2="y","N",IF(B2="y","N",IF(C2="y","N",IF(D2="y","N",IF(E2="y","N","")))))

How do I incorporate the second part into the formula?

Thanks in advance.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I would concatenate a2 b2 c2 d2 e2 there are only 32 permutations and use a lookup table to return the desired answer
 
Upvote 0
yynyyanswer28
nnnnnanswer1
nnnnyanswer2
formula returning answer28 isnnnynanswer3
nnnyyanswer4
=VLOOKUP(A2&B2&C2&D2&E2,mytable,2)nnynnanswer5
nnynyanswer6
nnyynanswer7
nnyyyanswer8
nynnnanswer9
nynnyanswer10
nynynanswer11
nynyyanswer12
nyynnanswer13
nyynyanswer14
nyyynanswer15
nyyyyanswer16
ynnnnanswer17
ynnnyanswer18
ynnynanswer19
ynnyyanswer20
ynynnanswer21
ynynyanswer22
ynyynanswer23
ynyyyanswer24
yynnnanswer25
yynnyanswer26
yynynanswer27
yynyyanswer28
yyynnanswer29
yyynyanswer30
yyyynanswer31
yyyyyanswer32

<colgroup><col width="64" span="13" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0
Try:
Code:
=IF(AND(A2="y",B2="y",C2="y",D2="y",E2="y"),"n",IF(AND(A2="n",B2="n",C2="n",D2="n",E2="n"),"y",""))
 
Upvote 0
Thanks Ronb and oldbrewer.

Ronb - Yours works if A2 thru to E2 all have data in the cells. However, it could be that just say A2 has an "n" in it. Your formula just doesn't show anything.

Thanks in advance :)
 
Upvote 0
This will ignore blanks,
Code:
=IF(AND(OR(A2="y",A2=""),OR(B2="y",B2=""),OR(C2="y",C2=""),OR(D2="y",D2=""),OR(E2="y",E2="")),"n",IF(AND(OR(A2="n",A2=""),OR(B2="n",B2=""),OR(C2="n",C2=""),OR(D2="n",D2=""),OR(E2="n",E2="")),"y",""))
 
Upvote 0
Hi

Try :-
Code:
=IF(OR(A2:E2="n"),"Y",IF(SUM(--(A2:E2="Y"))=5,"n",""))

entered with Control-Shift-Enter

hth
 
Upvote 0
This will ignore blanks,
Code:
=IF(AND(OR(A2="y",A2=""),OR(B2="y",B2=""),OR(C2="y",C2=""),OR(D2="y",D2=""),OR(E2="y",E2="")),"n",IF(AND(OR(A2="n",A2=""),OR(B2="n",B2=""),OR(C2="n",C2=""),OR(D2="n",D2=""),OR(E2="n",E2="")),"y",""))

This shortened formula will also ignore blanks:
Code:
=IF(AND(COUNTIF(A2:E2,"n")>0,COUNTIF(A2:E2,"y")=0),"y",IF(AND(COUNTIF(A2:E2,"y")>0,COUNTIF(A2:E2,"n")=0),"n",""))
 
Upvote 0

Forum statistics

Threads
1,214,895
Messages
6,122,128
Members
449,066
Latest member
Andyg666

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