Search for multiple text strings simultaneously in a single cell

geekylawyer

New Member
Joined
May 23, 2013
Messages
3
I have a spreadsheet that has relatively clean data, but at the end of every row is a long notes fields (often filled with several paragraphs of text). I'm trying to search inside each one of those notes to see if it contains certain boilerplate language / legalese / key words.

If I was just looking for one word, it would be easy -- I would write =IFERROR(IF(SEARCH("keyword",E2)>0,"Yes",""),""). That way, if the keyword is present, it returns "Yes", and if it's not present, it returns a blank.

What I want to do, though, if look for a long list of keywords simultaneously, and if ANY of those keywords are present, have it return a "Yes".

So I could do something like =IFERROR(IF(or(SEARCH("keyword1",E2)>0,SEARCH("keyword2",E2)>0,SEARCH("keyword3",E2)>0,SEARCH("keyword4",E2)>0)),"Yes",""),""), but that seems horribly inefficient. Especially since my list of keywords is likely to change over time.

So what I want it to do is search each cell by simultaneous reference to an ever-changing table of keywords (call it [KeywordTable]). And I can't figure out how to do that. The search function is resisting all of my efforts to put multiple search values / a range of words inside of it.

To reiterate: the goal is to look at one cell filled with text, ask "does the text in that cell contain any of the keywords contained in [KeywordTable]", and if the answer is "Yes" return yes, and if the answer is no return no (or blanks). That's all.
 
I am so excited! I have just used this and IT WORKED!!! Awesome.

Thank you so much.

The downside is that I will now be returning with other queries.


Best wishes

JohnB
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi John,

I forgot to say that i assumed the keywords inside the texts are not followed by any punctuation mark - period, comma, semicolon etc.

M.
 
Upvote 0
Hi Marcelo,

Is there a solution I can add to your formula to account for punctuation? I have the same scenario but need to identify file names (ex. toy.pdf).
 
Upvote 0
Hi Marcelo,

Is there a solution I can add to your formula to account for punctuation? I have the same scenario but need to identify file names (ex. toy.pdf).

**REVISED QUESTION PLEASE:
Is it possible to pull a keyword out of a string with no spaces? Trying to locate the substring within HTML code. The problem is the codes lack spaces. I need to search by the following keyword:
Keyword = "saginaw-chnfss.pdf"

Within a cell that has this string:
String = "<a href="http://www.website.com/pdfs/saginaw-chnfss.pdf">Click"

...and return only the Keyword (saginaw-chnfss.pdf).

Is that possible?
 
Upvote 0
**REVISED QUESTION PLEASE:
Is it possible to pull a keyword out of a string with no spaces? Trying to locate the substring within HTML code. The problem is the codes lack spaces. I need to search by the following keyword:
Keyword = "saginaw-chnfss.pdf"

Within a cell that has this string:
String = "<a href="http://www.website.com/pdfs/saginaw-chnfss.pdf">Click"

...and return only the Keyword (saginaw-chnfss.pdf).

Is that possible?

What is the oucome: Yes, 1, TRUE, or saginaw-chnfss.pdf (i.e., the keyword itself) or something else?
 
Upvote 0
What is the oucome: Yes, 1, TRUE, or saginaw-chnfss.pdf (i.e., the keyword itself) or something else?

Hi Aladin,

Here is the string that I neglected to post correctly = "
Code:
href="http://www.website.com/pdfs/saginaw-chnfss.pdf">Click

The outcome should be "saginaw-chnfss.pdf"

Right now I am experimenting with filtering the outcome using
Code:
=RIGHT(E2,LEN(E2)-FIND("/saginaw-",E2))
in one column, and
Code:
=LEFT
in the next. It's an ugly mess.

I truly appreciate your help.
 
Upvote 0
Hi Aladin,

Here is the string that I neglected to post correctly = "
Code:
href="http://www.website.com/pdfs/saginaw-chnfss.pdf">Click

The outcome should be "saginaw-chnfss.pdf"

Right now I am experimenting with filtering the outcome using
Code:
=RIGHT(E2,LEN(E2)-FIND("/saginaw-",E2))
in one column, and
Code:
=LEFT
in the next. It's an ugly mess.

I truly appreciate your help.

What is the exact keyword you are looking for if it's not "saginaw-chnfss.pdf"?
 
Upvote 0
The actual PDF file name is the exact keyword I am looking for. For the above example that would be "saginaw-chnfss.pdf"

If you have a list of such "keywords", list them in a convenient range. Select this range and name the selection Keys. Now you can invoke:

=LOOKUP(9.99999999999999E+307,SEARCH(Keys,E2),Keys)

where E2 houses a string of interest.
 
Upvote 0
Hi, the below formula is really helpful.
Question - is there a way to bring the word that was found, instead of "Yes" / "No"?
thanks a lot!



Hi and welcome to Mr Excel

Maybe...

=IF(SUMPRODUCT(--ISNUMBER(SEARCH(KeywordTable,E2))),"Yes","No")

where KeywordTable is a named range containing all keywords

M.
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

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