If cell contains a word from range, then return that word (not TRUE or FALSE)

northw

New Member
Joined
Jun 3, 2021
Messages
9
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
  2. MacOS
Hello,

I found something that is close to what I need, but instead of returning True/False, I need the actual word. Please see screenshot as an example.

And here is the link close to find I need, but returns T/F.
Cell contains many things

Thanks!
 

Attachments

  • Screenshot 2021-07-31 at 00.23.59.png
    Screenshot 2021-07-31 at 00.23.59.png
    44.9 KB · Views: 43

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
One approach but that assumed the color was the leading word in the item string.

Book2
ABCD
1ItemResultKeywords
2Green t-shirtGreenGreen
3Blue trousersBlueBlue
4Yellow socksYellowYellow
5Black TieNot FoundOrange
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=IFERROR(INDEX($D$1:$D$5,MATCH(LEFT(A2,FIND(" ",A2)-1),$D$1:$D$5,0)),"Not Found")
 
Upvote 0
Something like this
SheetNavigator.xlsm
BCDE
1itemsResultKeyword Range
2Green T-ShirtGreenGreen
3my Blue TrousersBlueBlue
4Yellow Socksyellowyellow
5Black TieNot foundorange
Sheet9
Cell Formulas
RangeFormula
C2:C5C2=IFERROR(INDEX($E$2:$E$5,MATCH(TRUE,SEARCH($E$2:$E$5,B2)>0,0)),"Not found")
 
Upvote 0
Solution
Thanks for the answer @kweaver , I should have thought about my example. The keyword (colours in this instance) could indeed be anywhere in the items. For example, it could be "Leave pattern brown scarf".

Do you think this is could be achievable?

Thank you for your time.
 
Upvote 0
Maybe try this VBA:

Code:
Dim i As Long, w As Long, j As Long, j2 As Long
j = Cells(Rows.Count, 4).End(xlUp).Row
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
 For j2 = 2 To j
 w = InStr(1, Cells(i, 1), Cells(j2, 4), vbTextCompare)
 If w <> 0 Then
 Cells(i, 2) = Cells(j2, 4)
 GoTo found
 Else
 Cells(i, 2) = "Not Found"
 End If
 Next j2
found: Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

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