Search a string for multiple key words

sahrens1

New Member
Joined
Jun 24, 2017
Messages
37
Simple question, that I cannot seem too find. Can anyone help me?

I would like a formula that searches a cell with a sentence for specific keywords. 10 max. If the keyword is found, then it would put the keyword in the cell.

So the cell to be searched would be G6
Keywords would be Theft, harassment, Police, Vandalism and "" (blank)

If those keywords were found, it would put in in the formula cell g7.

Any help?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Here's a UDF that will do that:
Code:
Function KeywordFIND(r As String) As String
Dim x, y As Long
x = Array("Theft", "Harassment", "Police", "Vandalism")
For y = LBound(x) To UBound(x)
    If InStr(1, r, x(y), vbTextCompare) Then KeywordFIND = KeywordFIND & x(y) & " "
Next
If Len(KeywordFIND) Then KeywordFIND = Left(KeywordFIND, Len(KeywordFIND) - 1)
End Function


Excel 2010
AB
1Theft harassment Other wordsTheft Harassment
Sheet1
Cell Formulas
RangeFormula
B1=keywordfind(A1)
 
Upvote 0
Try

=IFERROR(LOOKUP(2^15,SEARCH($D$1:$D$4,$G6),$D$1:$D$4),"")

D1:D4 is your list of keywords

IMPORTANT: There cannot be any blanks in D1:D4.
 
Last edited:
Upvote 0
I had interpreted it that there could be multiple keywords in the phrase and thus multiple results.
 
Upvote 0

Forum statistics

Threads
1,213,537
Messages
6,114,216
Members
448,554
Latest member
Gleisner2

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