Looking for keywords that matches exactly in a set of strings

jt9000

New Member
Joined
Feb 14, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I'm trying to search for an exact match of array of strings in each individual cell that contains long strings.
The strings could be comma delimited, which is considered acceptable, but I'm having trouble finding exact word match when a word contains the alphabets of another word. E.g. "Clamp" should not evaluate true when searching for "Lamp". Please advise how I can achieve this, below is what I have so far:
Book1.xlsx
ABCD
1StringEvaluated StateActual StateKeyword
2 LampTRUETRUELamp
3ClampTRUEFALSERight
4aagsdgFALSEFALSELeft
5asdfsFALSEFALSE
6LeftieTRUEFALSE
7LeftTRUETRUE
8Lamp, BrightTRUETRUE
Sheet1
Cell Formulas
RangeFormula
B2:B8B2=OR(ISNUMBER(SEARCH($D$2:$D$4,A2)))
Press CTRL+SHIFT+ENTER to enter array formulas.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Search in not case sensitive, use the Find function instead.
 
Upvote 0
Search in not case sensitive, use the Find function instead.
Case sensitivity is not crucial in my case. I'm more concerned about the keyword strings match the word is the search string exactly. E.g. When searching for "Lamp", "Clamp should not evaluate to TRUE, even though it contains the strings "lamp" after the "c". Same thing with "Leftie" shouldn't evaluate to true when searching for "Left". But "Lamp, Bright" should evaluate to TRUE when searching for "Lamp", since it matches the word "Lamp" exactly, even though it contains another word in the string.
 
Upvote 0
Hi,

Does this work for you:

Book3.xlsx
ABC
1StringResultKeyword
2 LampTRUELamp
3ClampFALSERight
4aagsdgFALSELeft
5asdfsFALSE
6LeftieFALSE
7LeftTRUE
8Lamp, BrightTRUE
Sheet1005
Cell Formulas
RangeFormula
B2:B8B2=ISNUMBER(LOOKUP(2,1/SEARCH(", "&$C$2:C$4&", ",", "&TRIM(A2)&", ")))
 
Upvote 0
Hi,

Does this work for you:

Book3.xlsx
ABC
1StringResultKeyword
2 LampTRUELamp
3ClampFALSERight
4aagsdgFALSELeft
5asdfsFALSE
6LeftieFALSE
7LeftTRUE
8Lamp, BrightTRUE
Sheet1005
Cell Formulas
RangeFormula
B2:B8B2=ISNUMBER(LOOKUP(2,1/SEARCH(", "&$C$2:C$4&", ",", "&TRIM(A2)&", ")))
Yes, that's exactly what I needed. Thank you so much!
Would you mind to explain how it works? I'm a bit perplexed how it allowed Clamp to not evaluate true due to lamp being part of the word
Thanks.
 
Upvote 0
Yes, that's exactly what I needed. Thank you so much!
Would you mind to explain how it works? I'm a bit perplexed how it allowed Clamp to not evaluate true due to lamp being part of the word
Thanks.

Within the formula, we isolated the Text with ", " ( comma & space ), so therefore:

", clamp, " does not equal to ", lamp, "

Also, I noticed in your posted sample, you have a leading Space in A2, that's why I also used TRIM
 
Upvote 0
Would you mind to explain how it works?
Add special letter (, or @ or |,...) to separate whole words. See how it works:
",Lamp," with ",Clamp," => FALSE
",Lamp," with ",Lamp, Bright," => TRUE
",Lamp," with ",Clamp, Bright," => FALSE
 
Upvote 0
If the suggested formula works for you then this slightly simpler one with less calculation required should also - column D below.

However, I am wondering about this statement.
cell that contains long strings.
The strings could be comma delimited,
If the cells contain long strings is every single word in the cell separated by comma space? If not then both column C & D formulas may return incorrect results - see row 9 below.

If it is possible that some words are separated by comma space and some just by space, then you may need to consider a formula more like column E.

22 02 15.xlsm
ABCDE
1StringKeywordPost #4Option 1Option 2
2LampLampTRUETRUETRUE
3ClampRightFALSEFALSEFALSE
4aagsdgLeftFALSEFALSEFALSE
5asdfsFALSEFALSEFALSE
6LeftieFALSEFALSEFALSE
7LeftTRUETRUETRUE
8Lamp, BrightTRUETRUETRUE
9Clamp, Right and LeftFALSEFALSETRUE
Keywords
Cell Formulas
RangeFormula
C2:C9C2=ISNUMBER(LOOKUP(2,1/SEARCH(", "&$B$2:B$4&", ",", "&TRIM(A2)&", ")))
D2:D9D2=COUNT(SEARCH(", "&$B$2:B$4&", ",", "&TRIM(A2)&", "))>0
E2:E9E2=COUNT(SEARCH(" "&$B$2:B$4&" "," "&SUBSTITUTE(A2,","," ")&" "))>0
 
Upvote 0
Solution
If the suggested formula works for you then this slightly simpler one with less calculation required should also - column D below.

However, I am wondering about this statement.

If the cells contain long strings is every single word in the cell separated by comma space? If not then both column C & D formulas may return incorrect results - see row 9 below.

If it is possible that some words are separated by comma space and some just by space, then you may need to consider a formula more like column E.

22 02 15.xlsm
ABCDE
1StringKeywordPost #4Option 1Option 2
2LampLampTRUETRUETRUE
3ClampRightFALSEFALSEFALSE
4aagsdgLeftFALSEFALSEFALSE
5asdfsFALSEFALSEFALSE
6LeftieFALSEFALSEFALSE
7LeftTRUETRUETRUE
8Lamp, BrightTRUETRUETRUE
9Clamp, Right and LeftFALSEFALSETRUE
Keywords
Cell Formulas
RangeFormula
C2:C9C2=ISNUMBER(LOOKUP(2,1/SEARCH(", "&$B$2:B$4&", ",", "&TRIM(A2)&", ")))
D2:D9D2=COUNT(SEARCH(", "&$B$2:B$4&", ",", "&TRIM(A2)&", "))>0
E2:E9E2=COUNT(SEARCH(" "&$B$2:B$4&" "," "&SUBSTITUTE(A2,","," ")&" "))>0
Thank you! That was exactly what I needed. I really appreciate everyone's help here :)
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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