Excel Lookup with Multiple Values based on wildcard match

Mike250

New Member
Joined
Apr 19, 2013
Messages
2
Hi there,

Long time lurker, first time register and poster. I've searched through the boards but couldn't quite find what I was after.
I've got two worksheets, in the first (Sheet1) is simply a list of terms (tags) that will be referenced later on.

A
1Happy
2Beach
3Invitation
4Super
5Bliss

<tbody>
</tbody>











In the second Sheet (Sheet2) a table of pages and their titles:

ABCD
1page_idauthor_idpage_titletag_list
221400102A Happy Person
321401102Superwoman
421402102Beach Bliss?
521403102The Invitation
621404102Back to the Future

<tbody>
</tbody>












I need to search Sheet 1 column A and if the word exists anywhere in Sheet 2 Column C then output the match in a comma separated list in column D.
So the word "Happy" is found in C2, so it gets written to D2.
The words "Beach" and "Bliss" are found in Sheet 2 C 4, so therefore D4 should have written: Beach, Bliss
The word "Super" is found in C3 (wildcard match to Superwoman) so D3 should have written: Super

End Result:

ABCD
1page_idauthor_idpage_titletag_list
221400102A Happy PersonHappy
321401102SuperwomanSuper
421402102Beach Bliss?Beach, Bliss
521403102The InvitationInvitation
621404102Back to the Future

<tbody>
</tbody>












Is there a VLOOKUP or INDEX function mash-up that I can use to achieve this? Thank you kindly in advance!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
First, add the following code as a module to your workbook usingAlt+F11...

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function

and invoke in D2 on Sheet2...

=REPLACE(aconcat(IF(ISNUMBER(SEARCH(Sheet1!$A$2:$A$6,C2)),","&Sheet1!$A$2:$A$6,"")),1,1,"")

which you need to confirm with control+shift+enter, not just enter, and copy down.
 
Upvote 0
That worked a treat Aladin, thank you.

There is a trailing comma (,) but I can handle that.

Great solution, you are most kind.
 
Upvote 0

Forum statistics

Threads
1,203,046
Messages
6,053,192
Members
444,644
Latest member
keepontruckinc4

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