Solved

Find words from a list in text of another column and return matching word if found

Posted on 2013-12-31
4
335 Views
Last Modified: 2013-12-31
Experts,

I have a list of words in a column e.g. names of fruit in A2:A8

Fruits
Oranges
Apples
Pears
Bananas
Kiwi
Cherries
Strawberries

And I have a column of rows of text that may or may not contain one of the words in the list. e.g. Comments in Col. C

Comments
My favorite fruit is apples.
Oranges are a good source of vitamin C.
Ripe pears taste good but so do bananas.
My favorite pet is a dog.


If one of the words in Fruits is found in the text, I want to enter the matching word in a cell in Col B, else leave it blank.

I'll take the first occurrence of a match.

What is a good way to do this?

Thanks in advance!
0
Comment
Question by:bobinorlando
  • 2
  • 2
4 Comments
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 39748705
Hello bobinorlando,

One way to do that is with this formula in B2 copied down

=IFERROR(LOOKUP(2^15,SEARCH(A$2:A$8,C2),A$2:A$8),"")

It actually matches in reverse order of the fruit in A2:A8 so for the text with "Pears" and "Bananas" it returns "Bananas" because that's lower down the list......is that a problem?

If so you can use this alternative (in Excel 2010 or later versions)

=IFERROR(INDEX(A$2:A$8,AGGREGATE(15,6,(SEARCH(A$2:A$8,C2)>0)*(ROW(A$2:A$8)-ROW(A$2)+1),1)),"")

that will match with the first fruit in the text so will give you "Pears" for the text "Ripe pears taste good but so do bananas"

see examples of both approaches attached

regards, barry
List-lookup.xlsx
0
 
LVL 1

Author Comment

by:bobinorlando
ID: 39749000
I see this works in your example file.
However, I'm having trouble applying it to my actual data (which is not the sample data I provided).

Can you plug some pseudo code into the formula to document what data goes where from my sample? e.g.

=IFERROR(LOOKUP(really big number,SEARCH(wordstofind,CellwithText),wordstofind),"iferrorprintthis")
0
 
LVL 1

Author Comment

by:bobinorlando
ID: 39749016
Never mind. I've got it now. Thanks!
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 39749149
Hello bobinorlando,

Excellent! -yes, this is a perfect generic version

=IFERROR(LOOKUP(really big number,SEARCH(wordstofind,CellwithText),wordstofind),"iferrorprintthis")

regards, barry
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now