VLOOKUP with CONCATENATED result (col_index_num)

mrnewbie

New Member
Joined
May 20, 2014
Messages
10
Hi there,

I am trying to figure out how to perform a VLOOKUP and return a concatenated result from multiple columns on the matched row. Below is how I want the data to end up looking:

Result Worksheet
ABC
1Full NamePhoneAddress
2Joe Smith1234123 Gumdrop Lane, Gummie, Candyland
3Sally May5678123 Snickers St., Cocoa, Candyland

<tbody>
</tbody>

Database Worksheet
ABCDE
1Full NamePhone Home StreetHome CityHome State
2Joe Smith1234123 Gumdrop LaneGummieCandyland
3Sally May5678123 Snickers St.CocoaCandyland

<tbody>
</tbody>

The VLOOKUP for the single match in the "Phone" column is working fine.

Example for B2 in "Result" Worksheet:

Code:
=IF(A2<>"",VLOOKUP(A2,'Database'!$A$2:$E$3,2,FALSE),"")

Now for cell C2 in the "Result" worksheet I want to concatenate C2:E2 in the "Database" worksheet (adding commas and spaces in between). Can someone please advise? Thanks a million!

Jared
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I can't upload my sample excel file, but I can at least give you a screenshot of the worksheets. Hopefully this helps!

Result Worksheet
worksheet_01.jpg


Database Worksheet
worksheet_02.jpg
 
Upvote 0
Copied your data exactly here our the formulas from C1 to C3

C1
Code:
{=IFERROR(INDEX(Database!$C$2:$C$5000,SMALL(IF(A2=Database!$A$2:$A$5001,ROW(Database!$A$1:$A$5000)-MIN(ROW(Database!$A$1:$A$5000))+1,""),ROW(Database!$A$1)))&", "&INDEX(Database!$D$2:$D$5000,SMALL(IF(A2=Database!$A$2:$A$5001,ROW(Database!$A$1:$A$5000)-MIN(ROW(Database!$A$1:$A$5000))+1,""),ROW(Database!$A$1)))," ")}

C2

Code:
{=IFERROR(INDEX(Database!$C$2:$C$5000,SMALL(IF(A3=Database!$A$2:$A$5001,ROW(Database!$A$1:$A$5000)-MIN(ROW(Database!$A$1:$A$5000))+1,""),ROW(Database!$A$1)))&", "&INDEX(Database!$D$2:$D$5000,SMALL(IF(A3=Database!$A$2:$A$5001,ROW(Database!$A$1:$A$5000)-MIN(ROW(Database!$A$1:$A$5000))+1,""),ROW(Database!$A$1)))," ")}

C3

Code:
{=IFERROR(INDEX(Database!$C$2:$C$5000,SMALL(IF(A3=Database!$A$2:$A$5001,ROW(Database!$A$1:$A$5000)-MIN(ROW(Database!$A$1:$A$5000))+1,""),ROW(Database!$A$1)))&", "&INDEX(Database!$D$2:$D$5000,SMALL(IF(A3=Database!$A$2:$A$5001,ROW(Database!$A$1:$A$5000)-MIN(ROW(Database!$A$1:$A$5000))+1,""),ROW(Database!$A$1)))," ")}

I changed the references slightly it looks like you were using phone number? to match I'm not sure. But try mine I used your data exactly, it should work if copy formula one into C1 and copy down that should work as well.

Let me know
 
Upvote 0
It is working now! I thought I could just Shift-click C2 and C3 in the Results worksheet then paste the formula and press Ctrl+Shift+Enter. I didn't realize I needed to copy a unique formula into each cell. Thanks for your help!
 
Upvote 0
Well you shouldn't have to copy a unique formula, you should be able to copy the formula down by dragging the box on the right corner.

Either way I am glad it works.
 
Upvote 0
That's working too =) Thanks for the tip.

Last question Say Joe Smith's Home City field (D2 on the database worksheet) is blank. The current formula still shows a comma in C2 of the results worksheet with no data after it. Is there a way to remove the comma if a particular field in the database worksheet returns no data?
 
Upvote 0
We can nest some IF Statements in there but I do agree with platonic, its a lot simpler to use helper columns. But I believe this solution allows you to constantly use new data with the same formula if the format stays consistent.

I can nest IF statements into our currently formula but its just going to grow the formula bigger and harder to fix later. Up to you, I will write one out in a second.
 
Upvote 0
Is there a way to remove the comma if a particular field in the database worksheet returns no data?

Do you mean changing "123 Gumdrop Lane, , Candyland" to show "123 Gumdrop Lane, Candyland" ?

If yes, then use below formula in F2 and copy down:

Code:
=SUBSTITUTE(C2&", "&D2&", "&E2,", ,",",")

After that vlookup column F as previously mentioned
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,107
Members
449,205
Latest member
ralemanygarcia

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