Search for multiple values within a single cell

nickhills1

New Member
Joined
Mar 20, 2024
Messages
8
Office Version
  1. 2021
Platform
  1. Windows
Hi All..

I need your wisdom please.
I need to be able to search for multiple values within a single cell, and return a related cell value if true.

In my example, I need to be able to select the search terms (Cow and Horse- column G&H) and then run a command that searches for Vets who treat Cow and Horse from the list, and then return the Vet name who does this. >> Results should be Vet1, Vet2

And then be able to select different animals (maybe Goat and Goldfish) and then run the search command to return Vet3

Thanks in advance for your assistance
 

Attachments

  • Screenshot 2024-03-20 151034.png
    Screenshot 2024-03-20 151034.png
    66.5 KB · Views: 42

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hello nickhills1

Mappe2
ABCDEFGH
1Vet NameAnimals treatedFilter
2Vet 1Dog, Horse, Cow, ChickenWAHRChickenVet 1
3Vet 2Cow, HorseWAHRCowYVet 2
4Vet 3Chicken, Goldfish, GoatFALSCHDog
5Vet 4Goldfish, HorseFALSCHGoat
6Vet 5ChickenFALSCHGoldfish
7Vet 6Chicken, CowFALSCHHorseY
8Vet 7Horse, DogFALSCH
9Vet 8Dog, Goat, ChickenFALSCH
Tabelle1
Cell Formulas
RangeFormula
H2:H3H2=FILTER(A2:A9,C2:C9)
C2:C9C2=SUM(ISNUMBER(SEARCH($F$2:$F$7,B2))*($G$2:$G$7="Y"))=COUNTA($G$2:$G$7)
Dynamic array formulas.
 
Upvote 0
Hello nickhills1

Mappe2
ABCDEFGH
1Vet NameAnimals treatedFilter
2Vet 1Dog, Horse, Cow, ChickenWAHRChickenVet 1
3Vet 2Cow, HorseWAHRCowYVet 2
4Vet 3Chicken, Goldfish, GoatFALSCHDog
5Vet 4Goldfish, HorseFALSCHGoat
6Vet 5ChickenFALSCHGoldfish
7Vet 6Chicken, CowFALSCHHorseY
8Vet 7Horse, DogFALSCH
9Vet 8Dog, Goat, ChickenFALSCH
Tabelle1
Cell Formulas
RangeFormula
H2:H3H2=FILTER(A2:A9,C2:C9)
C2:C9C2=SUM(ISNUMBER(SEARCH($F$2:$F$7,B2))*($G$2:$G$7="Y"))=COUNTA($G$2:$G$7)
Dynamic array formulas.
Sir, that is amazing!!! I have been looking for a solution for a couple of days (on and off). I owe you a virtual beer!!!

Sincerely, many thanks
 
Upvote 0
I would sound a word of caution on that formula. In this example that structure correctly returns Vet 7, but also returns Vet 5 who only treats fish, not dogs and cats.

Nickhills1.xlsm
ABCDEFGH
1Vet NameAnimals treatedFilter
2Vet 1Dog, Horsefly, Cow, ChickenFALSEChickenVet 5
3Vet 2Cow, HorseFALSECowVet 7
4Vet 3Chicken, Goldfish, GoatFALSEDogY
5Vet 4Goldfish, HorseFALSEGoat
6Vet 5Catfish, Spiny DogfishTRUEGoldfish
7Vet 6Chicken, CowFALSECatY
8Vet 7Horse, Dog, CatTRUE
9Vet 8Dog, Goat, ChickenFALSE
Sheet1
Cell Formulas
RangeFormula
H2:H3H2=FILTER(A2:A9,C2:C9)
C2:C9C2=SUM(ISNUMBER(SEARCH($F$2:$F$7,B2))*($G$2:$G$7="Y"))=COUNTA($G$2:$G$7)
Dynamic array formulas.


Instead you might try this modification

Nickhills1.xlsm
ABCDEFGH
1Vet NameAnimals treatedFilter
2Vet 1Dog, Horsefly, Cow, ChickenFALSEChickenVet 7
3Vet 2Cow, HorseFALSECow
4Vet 3Chicken, Goldfish, GoatFALSEDogY
5Vet 4Goldfish, HorseFALSEGoat
6Vet 5Catfish, Cod, Spiny DogfishFALSEGoldfish
7Vet 6Chicken, CowFALSECatY
8Vet 7Horse, Dog, CatTRUE
9Vet 8Dog, Goat, ChickenFALSE
Sheet2
Cell Formulas
RangeFormula
H2H2=FILTER(A2:A9,C2:C9)
C2:C9C2=COUNT(IF(G$2:G$7="Y",SEARCH(" "&F$2:F$7&","," "&B2&","),""))=COUNTA(G$2:G$7)
 
Upvote 0
Thanks both..

I see what you mean Peter, as the search terms are subsets of longer words..

I have applied the formula's to my sheet in question, and at the moment, when there are no search terms selected (no Y's in column G), it is returning all Vets..
Is there a way to force it to return no results (blank) if there are no Y's in column G?

TY
 
Upvote 0
Is there a way to force it to return no results (blank) if there are no Y's in column G?
Sure ..

Nickhills1.xlsm
ABCDEFGH
1Vet NameAnimals treatedFilter
2Vet 1Dog, Horsefly, Cow, ChickenTRUEChicken 
3Vet 2Cow, HorseTRUECow
4Vet 3Chicken, Goldfish, GoatTRUEDog
5Vet 4Goldfish, HorseTRUEGoat
6Vet 5Catfish, Cod, Spiny DogfishTRUEGoldfish
7Vet 6Chicken, CowTRUECat
8Vet 7Horse, Dog, CatTRUE
9Vet 8Dog, Goat, ChickenTRUE
Sheet2
Cell Formulas
RangeFormula
H2H2=IF(COUNTA(G2:G7),FILTER(A2:A9,C2:C9),"")
C2:C9C2=COUNT(IF(G$2:G$7="Y",SEARCH(" "&F$2:F$7&","," "&B2&","),""))=COUNTA(G$2:G$7)
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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