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:
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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:
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"))
if you wanted the user to be able to enter the values to match, you might do something like this:
I also think there might be an array function solution, but it isn't clear how I would write it.
=AND(COUNTIF(A1:A9,D1),COUNTIF(A1:A9,D2),COUNTIF(A1:A9,D3))
or=AND(COUNTIF(A1:A9,OFFSET(D1,0,0)),COUNTIF(A1:A9,OFFSET(D1,1,0)),COUNTIF(A1:A9,OFFSET(D1,2,0)))
This assumes that the user has typed values into D1:D3I also think there might be an array function solution, but it isn't clear how I would write it.
ASKER
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"),C OUNTIF(A:A ,"B" ),COUNTIF(A:A,"D")),"Yes", "No")
=IF(AND(COUNTIF(A:A,"A"),C
You're welcome alexisbr! Glad it worked for you.
$ 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.