Concatenate multiple value and remove duplicate

mduntley

Board Regular
Joined
May 23, 2015
Messages
134
Office Version
  1. 365
Platform
  1. Windows
Hello. I am working Microsoft Office 2016 and I am trying to get a formula to work. I have a custom formula to use the TEXTJOIN function in Excel 2016, but i want to show it once. I am wondering if someone can help me


Data Warehouse.xlsx
ABCD
1510000122AppleValue 4
2510000122763Cost CenterValue 1
3510000122763Cost CenterValue 1
4510000122763Cost Center & Payor1Value 2
5510000122763Cost Center & Payor2Value 2
6510000122763Cost CenterValue 2
7510000122763Cost CenterValue 2
8510000122859AppleValue 3
9
10My result now
11510000122763Cost Center Cost Center Cost Center & Payor1 Cost Center & Payor2 Cost Center Cost CenterValue 1 Value 1 Value 2 Value 2 Value 2 Value 2
12510000122432  
13510000122859AppleValue 3
14
15
16What I'm Trying to get
17510000122763Cost Center Cost Center & Payor1 Cost Center & Payor2 Cost CenterValue 1 Value 2 Value 2 Value 2
18510000122432Value 4
19510000122859AppleValue 3
Sheet4
Cell Formulas
RangeFormula
C11:C13C11=myvlookup(A11&B11,$A$1:$C$8,2)
D11:D13D11=myvlookup(A11&B11,$A$1:$C$8,3)


Here is the custom formula that i found for myvlookup

VBA Code:
Function myvlookup(pValue As String, pWorkRng As Range, pIndex As Long)
For Each rng In pWorkRng
    If rng = pValue Then
        xResult = xResult & vbNewLine & rng.Offset(0, pIndex - 1)
    End If
Next
myvlookup = Mid(xResult, 3)
End Function
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
How about using Power Query?

XLTemplate1
ABC
1NumberNameValue
2510000122AppleValue 4
3510000122763Cost CenterValue 1
4510000122763Cost CenterValue 1
5510000122763Cost Center & Payor1Value 2
6510000122763Cost Center & Payor2Value 2
7510000122763Cost CenterValue 2
8510000122763Cost CenterValue 2
9510000122859AppleValue 3
10
11
12
13
14NumberNameValue
15510000122AppleValue 4
16510000122763Cost Center Cost Center & Payor1 Cost Center & Payor2 Cost CenterValue 1 Value 2 Value 2 Value 2
17510000122859AppleValue 3
Sheet3


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Merge = Table.CombineColumns(Source,{"Name", "Value"},Combiner.CombineTextByDelimiter(";", QuoteStyle.None),"Merged"),
    Group = Table.Group(Merge, {"Number"}, {{"Data", each _, type table [Number=text, Merged=text]}}),
    Unique = Table.TransformColumns(Group,{{"Data", each List.Distinct(_[Merged])}}),
    Expand = Table.ExpandListColumn(Unique, "Data"),
    Split = Table.SplitColumn(Expand, "Data", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Name", "Value"}),
    ReGroup = Table.Group(Split, {"Number"}, {{"Data", each _, type table [Number=text, Name=nullable text, Value=nullable text]}}),
    Name = Table.AddColumn(ReGroup, "Name", each Text.Combine([Data][Name],Character.FromNumber(10))),
    Value = Table.AddColumn(Name, "Value", each Text.Combine([Data][Value],Character.FromNumber(10)))
in
    Value
 
Upvote 0
It seems that the Power Query will produce a new table, i am trying to update 2 cells in a document.
 
Upvote 0

Forum statistics

Threads
1,215,165
Messages
6,123,391
Members
449,098
Latest member
ArturS75

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