if the cell contains multiple text criteria then return the corresponding text criteria

greevek

New Member
Joined
Mar 15, 2017
Messages
8
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hi

Please can someone help, I have a formula that looks at a cell and returns a 1 if it matches the criteria and doesn't contain another specific word. Here is the formula:

Excel Formula:
=AND(COUNT(SEARCH({"Apple","Orange","Peach"},$A2))>0,COUNT(SEARCH({"Pears"},$A2))=0)

The problem I have is I want it to only return the result if all the criteria are met, i.e. the cell contains Apple, Orange, and Peach. At the minute it returns a 1 if any one of the 3 words is showing in that box, it does of course return 0 if Pears is included which is a result! Can anyone help me with my formula so it will return the result I am looking for? Also, not sure if this matters, but the words won't always be entered in the cell in the same order, it is randomly added from a quiz result.
(I Apologise if I haven't explained what I am looking for either.)
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
=AND(COUNT(SEARCH({"Apple","Orange","Peach"},$A2))=3,COUNT(SEARCH({"Pears"},$A2))=0)
 
Upvote 0
Solution
Edit - Better formula added as i was typing
 
Upvote 0
=AND(COUNT(SEARCH({"Apple","Orange","Peach"},$A2))=3,COUNT(SEARCH({"Pears"},$A2))=0)
Thank you so much, this was one of those formulas that I could not get my brain to figure out what I was missing. Works perfectly and I have already adapted it for other answers that have 2 or 4 answers in the cell. I knew I should have just come straight to the hive mind instead of struggling for 4 days!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top