# 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.

Alexis
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
=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.
Excel & VBA ExpertCommented:
Assuming you have values in the range A1:A9, the simplest approach without knowing your sheet layout, would be this.....

``````=IF(AND(COUNTIF(A1:A9,"A"),COUNTIF(A1:A9,"B"),COUNTIF(A1:A9,"C")),"Yes","No")
``````

Now Assuming you have values in the range A1:A9 and your lookup values are in the range M1:M3 where M1=A, M2=B and M3=C, then try this.....

``````=IF(COUNT(INDEX(MATCH(M1:M3,A1:A9,0),0))=3,"Yes","No")
``````

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Thank you all for your great work.  We are testing out the solutions and will get back to you.  Thanks again.  Alexis
Commented:
@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"))
``````
Commented:
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))
``````
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:D3

I also think there might be an array function solution, but it isn't clear how I would write it.
Author Commented:
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")
Excel & VBA ExpertCommented:
You're welcome alexisbr! Glad it worked for you.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.