Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# Excel - find matching text from array and lookup value

Posted on 2013-10-29
Medium Priority
597 Views
Experts, I have a column in excel that contains product descriptions (e.g. Col A)

Some of the descriptions contain specific product attributes that would be useful to have in a separate column. If so, then I would like to extract them and enter them into an adjacent column e.g. Col B).

For simple matches against one or two values I have been using something like this:

=IF(ISNUMBER(SEARCH("*DEED*",UPPER(\$A2))),"Deeded",IF(ISNUMBER(SEARCH("*MEMBERSHIP*",UPPER(\$A2))),"Membership",""))

That works great for one or two column values. Now however, I need to perform the same "contains" type of search and then match against a larger list of  values so that if the product description in ColA contains any of the following, then insert the matching word in Col B.

e.g.
Deluxe
Executive
House
Junior
Lockout
Loft
Luxury
Master
Penthouse
Plus
Presidential
Townhouse

Way too many for nested if formulas.

However, I can't figure out the right combination of other functions to use to solve this by first seeing if any one of the values exists within the text in ColA and if so, entering the one that matches into ColB.

Lookup, Vlookup, Index/Match or ??

0
Question by:bobinorlando
• 3
• 2

LVL 8

Expert Comment

ID: 39609192
try something like search

=IF(COUNT(SEARCH({"Romney","Obama","Gingrich"},C1)),1,"")

if text pattern is located in cell C1 then 1 is returned

0

LVL 23

Expert Comment

ID: 39609363
If you create a table of search values and the terms you want to return adjacent to them, say in X2:Y20

Then use a formula like:

=LOOKUP(10^10,SEARCH(\$X\$2:\$X\$20,A2),\$Y\$2:\$Y\$20)

This should search for the text that is in X2:X20 and find it anywhere in A2, then return the corresponding item from Y2:Y20.
0

LVL 1

Author Comment

ID: 39610235
Steveo that only gives me a true or false result whereas I need the result to be which of the values that was the match

NB_VC I couldn't get your solution to work  and I wasn't sure what 10^10 represented.
0

LVL 23

Accepted Solution

NBVC earned 2000 total points
ID: 39611319

I have 2 formulas because I am not sure of the actual lookup you want.

The first formula simply looks at list in column X and if any words are found in column A strings, then the keyword is assigned.

The second formula is very similar except it extracts the corresponding code from Y for the matching find.

Is this what you are looking for?

The 10^10 is basically a very large number.  And LOOKUP finds the last match that is smaller than or equal to the this lookup value of 10^10.  The SEARCH() function looks for positions of found items and so returns a number to represent that position or a #VALUE error if not found.  So hoping that there is a single match only, the LOOKUP finds that last and perhaps only numeric result and extracts from that position.
Book2.xls
0

LVL 1

Author Comment

ID: 39616762
Gary - LOL don't worry I already checked the other sites before I asked here. And I've been a paying member here for years so not to worry ;)
0

LVL 1

Author Closing Comment

ID: 39616767
Absolutely did the trick and I appreciate the explanation.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
###### Suggested Courses
Course of the Month13 days, 5 hours left to enroll