Find text within cell from a list of names

KongoBongo

New Member
Joined
Sep 5, 2007
Messages
28
Hello.
I have one column with text inputs (list A) and i need to check if these inputs contains
names from a list in another list B (not exact match). If so i need the formula to produce which of the names that were a "hit"

Example list A:

abc hero daf
fre gold
yellow bird
blue giraff

Check list B:
hero
gold
bird

if anything hits in list A (from B) i would like the name to be produced in adjacent column (example:hero)

any one that could help me?
thanks in advance!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hello.
I have one column with text inputs (list A) and i need to check if these inputs contains
names from a list in another list B (not exact match). If so i need the formula to produce which of the names that were a "hit"

Example list A:

abc hero daf
fre gold
yellow bird
blue giraff

Check list B:
hero
gold
bird

if anything hits in list A (from B) i would like the name to be produced in adjacent column (example:hero)

any one that could help me?
thanks in advance!
Try this...

List B in the range G2:G4.

List A starts in cell A2.

Enter this formula in B2 and copy down as needed:

=LOOKUP(1E100,SEARCH(G$2:G$4,A2),G$2:G$4)

If there is no match with list B then you'll get an error. One way to prevent that is:

=LOOKUP("zzzzz",CHOOSE({1,2},"",LOOKUP(1E100,SEARCH(G$2:G$4,A2),G$2:G$4)))

Also note, if the string contains more than one match from list B then the formula will match the word that is furthest down in list B.
 
Upvote 0
Hi,

This formula was very helpful for me too. Thanks!

I have a follow-up question, although after 7 years! This formula returns the name that matches and as you said, if the string contains more than one match from list B then the formula will match the word that is furthest down in list B. This is happening a lot in my output. But the problem here is that in the string in cell A2 it is looking at the words also in part. Is there a way to say that it should match the whole worlds in the string of text?

For example, in my data is a list of city names. I am looking for these names in the strings. when my string contains "warwick restaurants", it returns the value "wick" instead of "warwick" from the list of cities. Although 'wick' is in the list and in the string, i want it to return 'warwick' as that is the full word in the string.

Hope you can help!

Thanks,
Neha
 
Upvote 0
Hi, I too was having this problem recently and found the following technique to improve the accuracy of the output:

- Remove all punctuation from the column containing the cells you are searching with, eg using Find and Replace
- Add spaces around your list of towns, eg using =CONCATENATE(" ",A2," ")
- Now use the LOOKUP formula as below with your new list, and it will now only match Warwick in the text with Warwick in your list, thanks to the spaces.

It's not perfect but an improvement. Another thing I found to look out for is a lot of UK towns have names of common words, eg Street, Stone, etc so you may need to edit your original list to remove these or do some manual checking after applying the formula



Hi,

This formula was very helpful for me too. Thanks!

I have a follow-up question, although after 7 years! This formula returns the name that matches and as you said, if the string contains more than one match from list B then the formula will match the word that is furthest down in list B. This is happening a lot in my output. But the problem here is that in the string in cell A2 it is looking at the words also in part. Is there a way to say that it should match the whole worlds in the string of text?

For example, in my data is a list of city names. I am looking for these names in the strings. when my string contains "warwick restaurants", it returns the value "wick" instead of "warwick" from the list of cities. Although 'wick' is in the list and in the string, i want it to return 'warwick' as that is the full word in the string.

Hope you can help!

Thanks,
Neha
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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