Link to home
Start Free TrialLog in
Avatar of alexisbr
alexisbr

asked on

How to search col A in one Excel sheet for multiple values in different cells?

Hi.  We have a worksheet in which Column A looks like this:
User generated image
We want to search if A, B and C exist in different cells and return "Yes" if it does and "No" if it does not.  In this case, the function should return "Yes" but if the function searched for A, B and Z, it would return "No".

Is there a way to do this with functions and not use VBA?  I have looked at Search, Find, Lookup, Vlookup, etc. and can't seem to figure out how to do this.  It seems like it should be easy.

Thanks for your help.
Alexis
Avatar of Trent Smith
Trent Smith
Flag of United States of America image

=IF(ISNA(VLOOKUP($S22,$I$2:$I$55,1,0)),"No","Yes")
$ makes the row or column stay the same no matter where the formula is copied.
$ before column means the column stays the same.
$ before row means the row numbers don't change.
S22 is the value I was looking up.
$I$2:$I$55 is where I was looking up the value at.

This is formatted to return a Yes if the value is found and No if it isn't.
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alexisbr
alexisbr

ASKER

Thank you all for your great work.  We are testing out the solutions and will get back to you.  Thanks again.  Alexis
@Alexis

If you could do with True/False values, instead of Yes/No values, then you can simplify sktneer's formula to:
=AND(COUNTIF(A1:A9,"A"),COUNTIF(A1:A9,"B"),COUNTIF(A1:A9,"C"))

Open in new window

if you wanted the user to be able to enter the values to match, you might do something like this:
=AND(COUNTIF(A1:A9,D1),COUNTIF(A1:A9,D2),COUNTIF(A1:A9,D3))

Open in new window

or
=AND(COUNTIF(A1:A9,OFFSET(D1,0,0)),COUNTIF(A1:A9,OFFSET(D1,1,0)),COUNTIF(A1:A9,OFFSET(D1,2,0)))

Open in new window

This assumes that the user has typed values into D1:D3

I also think there might be an array function solution, but it isn't clear how I would write it.
Thanks to everyone.  We ended up using sktneer's solution as it worked for our scenario.  I just made one change to look at the entire A column.

=IF(AND(COUNTIF(A:A,"A"),COUNTIF(A:A,"B" ),COUNTIF(A:A,"D")),"Yes","No")
You're welcome alexisbr! Glad it worked for you.