2

How do I test for multiple conditions using Excel.

For Example:

I have Text in A2 'foo' and for each cell in column A:A that has 'foo' I want to Match B2 'Bar' to each cell in Column B:B. If the cell in A3 contains 'foo' and B3 contains 'bar', output "Match", Else "NA"

I have tried =IF(AND(A2=A:A,B2=B:B),"Match","NA"), but it does not work properly.

1 Answer 1

2

Try using COUNTIFS:

=IF(COUNTIFS(A:A,A2,B:B,B2)>1,"Match","NA")

Your idea was almost correct but faced the fact that the AND and OR operator in Excel are not array friendly, and also the fact that you already have a match on the line you are checking, so you need to have "more than 1" matches.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.