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
AB
MathGeometry, Algebra, Statistics

<tbody>
</tbody>

Worksheet 2
MathGeometry
MathAlgebra
MathStatistics

<tbody>
</tbody>

Thank you in advance!!
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
3,312
With Power Query

Column1Column2Column1Custom
MathGeometryMathGeometry,Algebra,Statistics
MathAlgebra
MathStatistics

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]
 

Jeannie11

New Member
Joined
Sep 28, 2019
Messages
3
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.
 

Jeannie11

New Member
Joined
Sep 28, 2019
Messages
3
Ok! I may be doing something wrong because I keep receiving an error... "column1 on the table is not found".
 

AhoyNC

Well-known Member
Joined
Oct 10, 2011
Messages
4,316
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
1Math
Sheet1
Excel Workbook
AB
1MathGeometry
2MathAlgebra
3HistoryHist1
4HistoryHist2
5MathStatistics
Sheet 2
 

Forum statistics

Threads
1,078,461
Messages
5,340,440
Members
399,375
Latest member
alwayssunny

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top