Forum Discussion
Jord4
Mar 11, 2020Copper Contributor
concatenate multiple
Hi guys,
So I have a couple rows of data, column A has users populated and column B has things assigned to them. In column A the users are listed out various times depending on what they have assigned to them in column B. I need to shorten that down to one cell per user but to keep all of the data in column B. Is there anyway of Doing this? I thought about concatenating column B so everything will be in one cell but I can't seem to work out how as when I sort Column A to remove duplicates it will also remove data from column B (lots of duplicates but need to keep them for each user)
Any help would be great 🙂
So I have a couple rows of data, column A has users populated and column B has things assigned to them. In column A the users are listed out various times depending on what they have assigned to them in column B. I need to shorten that down to one cell per user but to keep all of the data in column B. Is there anyway of Doing this? I thought about concatenating column B so everything will be in one cell but I can't seem to work out how as when I sort Column A to remove duplicates it will also remove data from column B (lots of duplicates but need to keep them for each user)
Any help would be great 🙂
3 Replies
- SergeiBaklanDiamond Contributor
If you mean something like this
few other variants
1) with dynamic array Excel
A: =UNIQUE(B3:B11) B: =TEXTJOIN(", ",1,FILTER($C$3:$C$11,$B$3:$B$11=E3))2) more traditional way
A: =IFERROR(INDEX($B$3:$B$11,AGGREGATE(15,6,1/(COUNTIF($H$2:$H2,$B$3:$B$11)=0)*(ROW($B$3:$B$11)-ROW($B$2)),1)),"") B: =TEXTJOIN(", ",1,IF($B$3:$B$11=$H3,$C$3:$C$11,""))and drag them down
3) Power Query if we name source as Range
let Source = Excel.CurrentWorkbook(), FilterRange = Table.SelectRows(Source, each ([Name] = "Range")), Range = FilterRange{[Name="Range"]}[Content], PromoteHeaders = Table.PromoteHeaders(Range, [PromoteAllScalars=true]), GroupA = Table.Group(PromoteHeaders, {"A"}, {{"B", each Text.Combine(_[B],", ")}}) in GroupA - Charla74Iron Contributor
You can create a user defined function for this per https://www.extendoffice.com/documents/excel/2706-excel-vlookup-return-multiple-values-in-one-cell.html (crucial part shown below):
1. Activate your worksheet which you want to vlookup multiple values into one cell.
2. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Vlookup to return multiple values in one cell
123456789101112Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long)'Update 20150310Dim rng As RangeDim xResult As StringxResult = ""For Each rng In pWorkRngIf rng = pValue ThenxResult = xResult & " " & rng.Offset(0, pIndex - 1)End IfNextMYVLOOKUP = xResultEnd Function- Jord4Copper ContributorThanks!