SOLVED

Trying to create an IF Statement in Excel if all answers are Yes the cell turn to "YES"

%3CLINGO-SUB%20id%3D%22lingo-sub-2467507%22%20slang%3D%22en-US%22%3ETrying%20to%20create%20an%20IF%20Statement%20in%20Excel%20if%20all%20answers%20are%20Yes%20the%20cell%20turn%20to%20%22YES%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2467507%22%20slang%3D%22en-US%22%3E%3CP%3ETrying%20to%20create%20an%20IF%20statement%20in%20Excel%20when%20all%20answers%20are%20YES%2C%20Column%20I%20turns%20to%20%22YES%22%20and%20if%20there%20is%20one%20answer%20that%20is%20%22No%22%20then%20column%20I%20turns%20to%20%22NO%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22HighFiveEm_0-1624312034123.png%22%20style%3D%22width%3A%20703px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F290380iBB38B6F37B3CC3DB%2Fimage-dimensions%2F703x232%3Fv%3Dv2%22%20width%3D%22703%22%20height%3D%22232%22%20role%3D%22button%22%20title%3D%22HighFiveEm_0-1624312034123.png%22%20alt%3D%22HighFiveEm_0-1624312034123.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2467507%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2467590%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20create%20an%20IF%20Statement%20in%20Excel%20if%20all%20answers%20are%20Yes%20the%20cell%20turn%20to%20%22YES%26amp%3Bquot%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2467590%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1060092%22%20target%3D%22_blank%22%3E%40HighFiveEm%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat's%20like%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(%20PRODUCT(%20(C4%3AC9%3D%22yes%22)*1)%20*%0A%20%20%20%20%20PRODUCT(%20(E4%3AE9%3D%22yes%22)*1)%20*%0A%20%20%20%20%20PRODUCT(%20(G4%3AG7%3D%22yes%22)*1)%20%2C%0A%20%22yes%22%2C%20%22no%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIf%20you%20are%20on%20365%20you%20don't%20need%20PRODUCT%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2467613%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20create%20an%20IF%20Statement%20in%20Excel%20if%20all%20answers%20are%20Yes%20the%20cell%20turn%20to%20%22YES%26amp%3B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2467613%22%20slang%3D%22en-US%22%3EThank%20you%20Sergei...this%20worked%20fantastic.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2468571%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20create%20an%20IF%20Statement%20in%20Excel%20if%20all%20answers%20are%20Yes%20the%20cell%20turn%20to%20%22YES%26amp%3B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2468571%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1060092%22%20target%3D%22_blank%22%3E%40HighFiveEm%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2538931%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20create%20an%20IF%20Statement%20in%20Excel%20if%20all%20answers%20are%20Yes%20the%20cell%20turn%20to%20%22YES%26amp%3B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2538931%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20want%20to%20update%20it%20also%20if%20%22Yes%22%20or%20%22N%2FA%22%20then%20it%20is%20Yes.%26nbsp%3B%20But%20if%20%22No%22%20in%20any%20question%20then%20it%20returns%20a%20%22NO%22.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2539037%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20create%20an%20IF%20Statement%20in%20Excel%20if%20all%20answers%20are%20Yes%20the%20cell%20turn%20to%20%22YES%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2539037%22%20slang%3D%22en-US%22%3EI%20used%20the%20following%20formula%20which%20worked%20much%20better%20but%20still%20need%20to%20include%20the%20N%2FA.%3CBR%20%2F%3E%3CBR%20%2F%3E%3DIF(COUNTIF(C4%3AC9%2C%22%26lt%3B%26gt%3BYES%22)%2BCOUNTIF(E4%3AE9%2C%22%26lt%3B%26gt%3BYES%22)%2BCOUNTIF(G4%3AG7%2C%22%26lt%3B%26gt%3BYES%22)%2C%20%22NO%22%2C%20%22YES%22)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2539090%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20create%20an%20IF%20Statement%20in%20Excel%20if%20all%20answers%20are%20Yes%20the%20cell%20turn%20to%20%22YES%26amp%3Bquot%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2539090%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1060092%22%20target%3D%22_blank%22%3E%40HighFiveEm%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDo%20you%20mean%20%23N%2FA%20error%20returned%20by%20function%20or%20text%20%22N%2FA%22%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Trying to create an IF statement in Excel when all answers are YES, Column I turns to "YES" and if there is one answer that is "No" then column I turns to "NO".

 

HighFiveEm_0-1624312034123.png

 

17 Replies
best response confirmed by allyreckerman (Microsoft)
Solution

@HighFiveEm 

That's like

=IF( PRODUCT( (C4:C9="yes")*1) *
     PRODUCT( (E4:E9="yes")*1) *
     PRODUCT( (G4:G7="yes")*1) ,
 "yes", "no")

If you are on 365 you don't need PRODUCT

Thank you Sergei...this worked fantastic.

@Sergei Baklan 

 

So I want to update it also if "Yes" or "N/A" then it is Yes.  But if "No" in any question then it returns a "NO".

I used the following formula which worked much better but still need to include the N/A.

=IF(COUNTIF(C4:C9,"<>YES")+COUNTIF(E4:E9,"<>YES")+COUNTIF(G4:G7,"<>YES"), "NO", "YES")

@HighFiveEm 

Do you mean #N/A error returned by function or text "N/A" ?

@HighFiveEm 

In general you may check the opposite - if at least one No then No else Yes. Like

=IF(COUNTIFS(E4:E9, "No")+COUNTIFS(G4:G7, "No")+COUNTIFS(C4:C9, "No"), "No", "Yes")

if you prefer COUNTIFS()

Text "N/A", if someone answers a question with a "N/A" the overall is still a "YES"

@HighFiveEm 

Thank you. Does previous formula to check "no" works, or that could be other variants except "yes", "no" and "n/a" ?

If i have two columns, and i type yes or no in the boxes how can i create a formula that if both columns in a row is no the answer will be no? but if one answer is yes and 1 is no the answer should be yes?

@MindyS 

Depends on how your data is structured, as variant that could be

image.png

@HighFiveEm 

A new option,  Naming your table data, one can select the columns with answers and then test for the presence of a "no"

= AND(CHOOSECOLS(data,2,4,6)<>"no")

There are other ways of doing this but CHOOSECOLS is one of the latest.

 

@Peter Bartholomew 

The columns are just like you are showing in the example. I cannot get any formula to work. I have tried 

=IF(AND(H8:I8="No")<>"no")

=AND(CHOOSECOLS(H8:I8="no")<>"no")

I get errors with both of them. 

 

@MindyS 

1) On which Excel version/platform you are?

2) Which exactly error do you have?

 

At least

=IF(AND(H8:I8="No")<>"no")

never works. AND() returns  TRUE or FALSE and it never equals to "no"

@MindyS 

My apologies for creating confusion.  There were many aspects of traditional spreadsheets that I found distasteful, so my interest is now the new opportunities to create solutions that modern Excel offers.  However, something similar in concept is possible using INDEX (I think it was Daniel Ferry that referred to the function as 'the Imposing Index'). 

= AND(INDEX(data,{1;2;3;4;5;6},{2,4,6})<>"no")

Dressed up, even that could be written

= LET(
      status, INDEX(data,{1;2;3;4;5;6},{2,4,6}),
      passes, status<>"no",
      AND(passes)
  )

which is more open to step by step testing.