Search for multiple words in a cell

Stuck1

Board Regular
Joined
Sep 3, 2009
Messages
73
Hi all,

Hope you can help. I'm trying to write a formula that will flag when a cell has a certain word in it. However, I want to search for various words. So does this this sentence in A1: "Search for multiple words in a cell"

contain the words "search", "find", "hunt" or "discover" in it?

I've tried with nesting OR's in SEARCH, MATCH and FIND, but I keep getting errors.

Thanks for any help.
 
Many thanks for the prompt and excellent response, but is there a way I can point the formula at a cell or a range rather than having the target words coded within the syntax?

I've tried :IF(SUM(COUNTIF(A6,C1),COUNTIF(A6,C2),COUNTIF(A6,C3),COUNTIF(A6,C4)),"No","Yes")
but it doesb't work.

If you just want a Yes/No or a 1/0 marking...

=IF(ISNUMBER(LOOKUP(9.99999999999999E+307,SEARCH(C1:C4,A6)),"Yes","No")

=ISNUMBER(LOOKUP(9.99999999999999E+307,SEARCH(C1:C4,A6))+)

would also suffice.
 
Upvote 0
Just to add tweak, can anyone suggest a way to enter all the target words into just one cell? I'd like to build a sheet that allows users to enter a series of keywords (seperated by a comma). If the keyword is matched a list (of all the sentences) will appear.

Feel free to point me in the direction of any relevant webpages, I've not been able to find a soloution that meets my needs.

Thanks again everyone.
 
Upvote 0
Just to add tweak, can anyone suggest a way to enter all the target words into just one cell? I'd like to build a sheet that allows users to enter a series of keywords (seperated by a comma). If the keyword is matched a list (of all the sentences) will appear.

Feel free to point me in the direction of any relevant webpages, I've not been able to find a soloution that meets my needs.

Thanks again everyone.
That would require a VBA solution.

I'm not much of a programmer so someone else will need to help you with that.

Good luck!
 
Upvote 0
Just to add tweak, can anyone suggest a way to enter all the target words into just one cell? I'd like to build a sheet that allows users to enter a series of keywords (seperated by a comma). If the keyword is matched a list (of all the sentences) will appear.

Feel free to point me in the direction of any relevant webpages, I've not been able to find a soloution that meets my needs.

Thanks again everyone.

Add the following code (FastExcel aka Charles Williams) to your workbook...

_________________________

Public Function EVAL(theInput As Variant) As Variant
'
' if UDF evaluate the input string as though it was on this sheet
' else evaluate for activesheet
'
Dim vEval As Variant
Application.Volatile
On Error GoTo funcfail
If Not IsEmpty(theInput) Then
If TypeOf Application.Caller.Parent Is Worksheet Then
vEval = Application.Caller.Parent.Evaluate(CStr(theInput))
Else
vEval = Application.Evaluate(CStr(theInput))
End If
If IsError(vEval) Then
EVAL = CVErr(xlErrValue)
Else
EVAL = vEval
End If
End If
Exit Function
funcfail:
EVAL = CVErr(xlErrNA)
End Function
_________________________

Given EVAL, consider:

[TABLE="width: 409"]
<colgroup><col style="width: 149pt; mso-width-source: userset; mso-width-alt: 7054;" width="198"> <col style="width: 48pt;" span="3" width="64"> <col style="width: 116pt; mso-width-source: userset; mso-width-alt: 5518;" width="155"> <tbody>[TR]
[TD="class: xl63, width: 198, bgcolor: transparent"]go home find and discover[/TD]
[TD="class: xl63, width: 64, bgcolor: transparent"]Yes[/TD]
[TD="class: xl63, width: 64, bgcolor: transparent"] [/TD]
[TD="class: xl63, width: 64, bgcolor: transparent"] [/TD]
[TD="class: xl63, width: 155, bgcolor: transparent"]search,find,hunt,discover[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]None looked for this[/TD]
[TD="class: xl63, bgcolor: transparent"]No[/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[/TR]
</tbody>[/TABLE]

E1 houses a set of relevant search tokens, each separated with a comma.

A1:A2 houses some target strings in which to look for the occurrence of any in E1 specified token.

In B1 enter and copy down:
Rich (BB code):
=IF(ISNUMBER(LOOKUP(9.9999999999999E+307,
  SEARCH(eval("{"&CHAR(34)&SUBSTITUTE($E$1,",",
   CHAR(34)&","&CHAR(34))&CHAR(34)&"}"),A1))),"Yes","No")
 
Upvote 0
I hope it's okay to restart this old(ish) thread of mine, I have a question relating to the same peice of work.

I got a great response to the original question and have employed Aladin's solution in one spreadsheet and Biz's solution in another. My question relates to Biz's soloution to flag when target words appears in a cell:

=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(KEYWORD1,$B13))))>0,$C13,"")

- Where KEYWORD is a range of 6 keywords
- B13 is the target cell that is searched
- C13 is the value that is returned if the word is found (NULL is returned if there is no match.

My question is: How do I add a further rule to set the formula to ignore a successful match if it contains other words?

For example, if the KEYWORDS are "bread", "butter", "toast"
and the target cell contains "bread, milk, cereal"
How can I set it to ignore the match if the word "milk" appears?

It's kinda like Googles -"not this word" search function.

I hope this makes sense and I hope some can help.

Many thanks.
 
Upvote 0
I have a solution of sorts:

=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(NOTWORD,$A4))))=1,"DON'T FLAG",IF(SUMPRODUCT(--(ISNUMBER(SEARCH(KEYWORD,$A4))))>0,"FLAG","DON'T FLAG"))

If there's a more efficient way, I'd like to see it as the file is pretty big :)
 
Upvote 0
I hope it's okay to restart this old(ish) thread of mine, I have a question relating to the same peice of work.

I got a great response to the original question and have employed Aladin's solution in one spreadsheet and Biz's solution in another. My question relates to Biz's soloution to flag when target words appears in a cell:

=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(KEYWORD1,$B13))))>0,$C13,"")

- Where KEYWORD is a range of 6 keywords
- B13 is the target cell that is searched
- C13 is the value that is returned if the word is found (NULL is returned if there is no match.

My question is: How do I add a further rule to set the formula to ignore a successful match if it contains other words?

For example, if the KEYWORDS are "bread", "butter", "toast"
and the target cell contains "bread, milk, cereal"
How can I set it to ignore the match if the word "milk" appears?

It's kinda like Googles -"not this word" search function.

I hope this makes sense and I hope some can help.

Many thanks.

KEYWORDS
bread
butter
toast

B13 contains:
bread, milk, cereal

Would you elaborate on what it means to ignore "milk" for KEYWORDS does not count such an entry?
 
Upvote 0
I've been looking EVERYWHERE for a formula like this! You have no idea how much time this will save me (even though I spent twice as much time looking for a formula as it would have taken to do manually haha!). Thank you!!!!!

Another variant.

Create Named Range called MultiSearch



={"search","find","hunt","discover"}

Sheet1


ABC
tyru No
search Yes
hunt Yes
discover Yes
You No
find Yes
find Yes
find Yes


<colgroup>
<colgroup><col bold;?="" 30px;="">
<colgroup><col style="width: 56px;">
<colgroup><col style="width: 56px;">
<colgroup><col style="width: 56px;"></colgroup>
<tbody>


[TD="bgcolor: #CACACA, align: center"]6[/TD]



[TD="bgcolor: #CACACA, align: center"]7[/TD]



[TD="bgcolor: #CACACA, align: center"]8[/TD]



[TD="bgcolor: #CACACA, align: center"]9[/TD]



[TD="bgcolor: #CACACA, align: center"]10[/TD]



[TD="bgcolor: #CACACA, align: center"]11[/TD]



[TD="bgcolor: #CACACA, align: center"]12[/TD]



[TD="bgcolor: #CACACA, align: center"]13[/TD]


</tbody>


Spreadsheet Formulas

CellFormula
C6=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(MultiSearch,A6))))>0,"Yes","No")
C7=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(MultiSearch,A7))))>0,"Yes","No")
C8=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(MultiSearch,A8))))>0,"Yes","No")
C9=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(MultiSearch,A9))))>0,"Yes","No")
C10=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(MultiSearch,A10))))>0,"Yes","No")
C11=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(MultiSearch,A11))))>0,"Yes","No")
C12=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(MultiSearch,A12))))>0,"Yes","No")
C13=IF(SUMPRODUCT(--(ISNUMBER(SEARCH(MultiSearch,A13))))>0,"Yes","No")


<tbody>

</tbody>


<tbody>

</tbody>


Biz
 
Upvote 0
I've been looking EVERYWHERE for a formula like this! You have no idea how much time this will save me (even though I spent twice as much time looking for a formula as it would have taken to do manually haha!). Thank you!!!!!

=ISNUMBER(LOOKUP(9.99999999999999E+307,SEARCH(MultiSearch,A6)))+1

is faster, where a 1 means a hit and a 0 a miss.
 
Upvote 0

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