VLOOKUP Multiple value return in Single Cell with Repitiion

Jeannie11

New Member
Joined
Sep 28, 2019
Messages
3
Hello -

I have a reference value that I'm looking to return the associated values into one cell but am not sure how to do that. For example, assume the reference value is MATH in worksheet 1 and in Worksheet 2 Math is associated with Geometry, Algebra, Statistics. I'd like to return both Geometry and Algebra in one cell in worksheet 1, and separate by commas.

Worksheet 1
[TABLE="width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD]Math[/TD]
[TD]Geometry, Algebra, Statistics[/TD]
[/TR]
</tbody>[/TABLE]

Worksheet 2
[TABLE="width: 500"]
<tbody>[TR]
[TD]Math[/TD]
[TD]Geometry[/TD]
[/TR]
[TR]
[TD]Math[/TD]
[TD]Algebra[/TD]
[/TR]
[TR]
[TD]Math[/TD]
[TD]Statistics[/TD]
[/TR]
</tbody>[/TABLE]

Thank you in advance!!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
With Power Query

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Column1[/td][td=bgcolor:#5B9BD5]Column2[/td][td][/td][td=bgcolor:#70AD47]Column1[/td][td=bgcolor:#70AD47]Custom[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]Math[/td][td=bgcolor:#DDEBF7]Geometry[/td][td][/td][td=bgcolor:#E2EFDA]Math[/td][td=bgcolor:#E2EFDA]Geometry,Algebra,Statistics[/td][/tr]

[tr=bgcolor:#FFFFFF][td]Math[/td][td]Algebra[/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]Math[/td][td=bgcolor:#DDEBF7]Statistics[/td][td][/td][td][/td][td][/td][/tr]
[/table]


Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Column1"}, {{"Count", each _, type table}}),
    Extract = Table.TransformColumns(Table.AddColumn(Group, "Custom", each List.Distinct(Table.Column([Count],"Column2"))), {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    Extract[/SIZE]
 
Upvote 0
Thank you for replying!

I'm not familiar with what Power Query is and not seeing an icon for it on the Excel. Could you please guide me as to what that means and where I place this code? Assuming I'd need to tweak the code as well so that it looks to the right cells in my spreadsheet.
 
Upvote 0
Power Query == Get&Transform

screenshot-107.png



PQ works with Tables
select your range, choose From Table and it will open PQ Editor then copy code from the post, open Advanced Editor and replace code there with copied code
be sure your table headers are the same as in my post
 
Last edited:
Upvote 0
Ok! I may be doing something wrong because I keep receiving an error... "column1 on the table is not found".
 
Upvote 0
If you have Excel 2016 or later with the TEXTJOIN function then here is another option.
This is an array formula and must be entered with CTRL-SHIFT-ENTER.

Excel Workbook
AB
1MathGeometry, Algebra, Statistics
Sheet1
Excel Workbook
AB
1MathGeometry
2MathAlgebra
3HistoryHist1
4HistoryHist2
5MathStatistics
Sheet 2
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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