Formula to find words from a list in cell

Stuepef

Board Regular
Joined
Oct 23, 2017
Messages
128
Office Version
  1. 2021
Platform
  1. Windows
I have a list of words in a range and I would like to create a formula to see if those words are within a cell value. Rather than the formula saying TRUE or FALSE, I would like the formula to provide the actual word that it found OR a numeric value for where that words position is in the list (i.e. if the formula found the 3rd word in the list, then the formula would provide a 3)

Here is the data:

Untitled.png
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
How about this?

Excel
DEF
1List
2Orange
3Purple
4Green
5Blue
6Maroon
7Yellow
8Light Green
9Beige
10Navy Blue
11
12CellOutcome
13Orange Turbo CarOrange
14Orange Turbo CarOrange
15Orange Turbo CarOrange
16Orange Turbo CarOrange
17Purple LamboPurple
18Purple LamboPurple
19Purple LamboPurple
20Beige SeatsBeige
21Beige SeatsBeige
22Beige SeatsBeige
Sheet3
Cell Formulas
RangeFormula
F13:F22F13=INDEX($D$2:$D$10,AGGREGATE(15,6,ROW($D$2:$D$10)/SEARCH($D$2:$D$10,D13),1)-1)
 
Upvote 0
This updated version is a bit better. The old one will fail if the color isn't at the beginning of the sentence.

Excel Formula:
=INDEX($D$2:$D$10,AGGREGATE(15,6,ROW($D$2:$D$10)/XMATCH("*"&$D$2:$D$10&"*",D13,2),1)-ROW($D$1))
 
Upvote 2
Solution
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
This updated version is a bit better. The old one will fail if the color isn't at the beginning of the sentence.

Excel Formula:
=INDEX($D$2:$D$10,AGGREGATE(15,6,ROW($D$2:$D$10)/XMATCH("*"&$D$2:$D$10&"*",D13,2),1)-ROW($D$1))
Thank you - works great!!
 
Upvote 0
I know it's not part of the OP, but is there a way to return more than one match if found in the string? For instance if D13 = "Orange Turbo Blue Car". Is there a formula that would return "Orange, Blue"? I am imagining the use of TEXTJOIN on a spilled result. I believe I have seen a LAMBDA that will do that...wondering if it can be done with a standard formula.

I am not trying to hijack this thread, just expand on it...:)

Thanks,

Doug
 
Upvote 0
As you have 365 another option is
Fluff.xlsm
DEF
1List
2Orange
3Purple
4Green
5Blue
6Maroon
7Yellow
8Light Green
9Beige
10Navy Blue
11
12Cell
13Orange Turbo CarOrange
14Orange Turbo CarOrange
15Orange Turbo CarOrange
16Orange Turbo CarOrange
17Purple Green LamboPurple, Green
18Purple LamboPurple
19Purple LamboPurple
20Beige SeatsBeige
21Beige SeatsBeige
22Beige SeatsBeige
Sheet5
Cell Formulas
RangeFormula
F13:F22F13=TEXTJOIN(", ",,XLOOKUP(TEXTSPLIT(D13," "),$D$2:$D$10,$D$2:$D$10,""))
 
Upvote 0
Nice, Fluff.

I came up with an alternate too...
Excel Formula:
=TEXTJOIN(", ",TRUE,FILTER($D$2:$D$10,ISNUMBER(SEARCH($D$2:$D$10,D13))))
In my mind, I thought there was a way to write a single formula that would spill down the Outcome range, but I think you have to copy the formula down.

Thanks,

Doug
 
Upvote 0
I guess BYROW does that...
Excel Formula:
=BYROW(D13:D22,LAMBDA(x,TEXTJOIN(", ",TRUE,FILTER($D$2:$D$10,ISNUMBER(SEARCH($D$2:$D$10,x))))))
 
Upvote 0
As you have 365 another option is
Fluff.xlsm
DEF
1List
2Orange
3Purple
4Green
5Blue
6Maroon
7Yellow
8Light Green
9Beige
10Navy Blue
11
12Cell
13Orange Turbo CarOrange
14Orange Turbo CarOrange
15Orange Turbo CarOrange
16Orange Turbo CarOrange
17Purple Green LamboPurple, Green
18Purple LamboPurple
19Purple LamboPurple
20Beige SeatsBeige
21Beige SeatsBeige
22Beige SeatsBeige
Sheet5
Cell Formulas
RangeFormula
F13:F22F13=TEXTJOIN(", ",,XLOOKUP(TEXTSPLIT(D13," "),$D$2:$D$10,$D$2:$D$10,""))
Thank you - one day I will learn 365 formulas!
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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