=TEXTJOIN(", ",TRUE,UNIQUE(IF(Table1[Category]=Table2[Unique Categories],Table1[Items to Join],"")))
Works a treat, I use it a lot.
Do you know how to join texts from a column into a cell without duplicates in Excel? And what if join texts in a column without duplicates based on specific cell value? This article provides methods to solve the problems.
Join texts in a column without duplicates with formula
Join texts in a column without duplicates based on another cell value with VBA code
Easily join texts in a column based on another cell value with an amazing tool
More tutorial for combining cells…
As the below screenshot shown, you want to join texts in column A into a single cell without duplicates. Please do as follows.
1. Select a blank cell, copy the below formula into it and press the Alt + Shift + Enter keys at the same time.
=TEXTJOIN(", ", TRUE, IF(MATCH(A2:A12, A2:A12, 0)=MATCH(ROW(A2:A12), ROW(A2:A12)), A2:A12, ""))
Note: In the formula, “, ” is the separator of the combined texts; A2:A12 is the column cells you will join together. Please change them as you need.
Now the texts in specified column are joined without duplicates.
Sometimes, you may need join texts in a column without duplicates based on value in another cell, as below screenshot shown, you can get it down as follows.
1. In the worksheet contains the texts you will join, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module, and then copy the below VBA code into the Module code window.
VBA code: Join texts in a column without duplicates based on another cell value
Sub JoinTextsWithoutDuplicates() 'Updated by Extendoffice 20190924 Dim xRg As Range Dim xArr As Variant Dim xCell As Range Dim xTxt As String Dim I As Long Dim xDic As Object Dim xValue Dim xStr, xStrValue As String Dim xB As Boolean On Error Resume Next xTxt = ActiveWindow.RangeSelection.Address Set xRg = Application.InputBox("Please select the data range", "Kutools for Excel", xTxt, , , , , 8) Set xRg = Application.Intersect(xRg, xRg.Worksheet.UsedRange) If xRg Is Nothing Then Exit Sub If xRg.Areas.Count > 1 Then MsgBox "Does not support multiple selections", , "Kutools for Excel" Exit Sub End If If xRg.Columns.Count <> 2 Then MsgBox "There must be only two columns in the selected range", , "Kutools for Excel" Exit Sub End If xArr = xRg Set xDic = CreateObject("Scripting.Dictionary") xDic.CompareMode = 1 For I = 1 To UBound(xArr) If Not xDic.Exists(xArr(I, 1)) Then xDic.Item(xArr(I, 1)) = xDic.Count + 1 xArr(xDic.Count, 1) = xArr(I, 1) xArr(xDic.Count, 2) = xArr(I, 2) Else xStrValue = xArr(I, 2) xB = True For Each xStr In Split(xArr(xDic.Item(xArr(I, 1)), 2), ",") If xStr = xStrValue Then xB = False Exit For End If Next If xB Then xArr(xDic.Item(xArr(I, 1)), 2) = xArr(xDic.Item(xArr(I, 1)), 2) & "," & xArr(I, 2) End If End If Next Sheets.Add.Cells(1).Resize(xDic.Count, 2).Value = xArr End Sub
3. Press the F5 key to run the code. In the popping up Kutools for Excel dialog, select the range including both the values you will join texts based on and the texts you will join, and then click the OK button.
Then the unique values are extracted and their corresponding unique texts in another column are joined and placed in a new worksheet.
Before applying Kutools for Excel, please download and install it firstly.
Note: As the utility will directly apply in the original range, please make a copy of the original data before applying the below operation.
1. Select the range (include the texts you will join and the value you will join texts based on), click Kutools > Content > Advanced Combine Rows. See screenshot:
2. In the Advanced Combine Rows dialog, please do as follows:
Then you can see all the texts in specified column are joined based on the key column. See screenshot:
If you want to have a free trial ( 30-day) of this utility, please click to download it, and then go to apply the operation according above steps.
Combine duplicate rows and sum the values in Excel
In Excel, you may always meet this problem, when you have a range of data which contains some duplicate entries, and now you want to combine the duplicate data and sum the corresponding values in another column, how could you solve this problem? Try the methods in this article.
Combine Multiple Cells Into A Cell With Space, Commas or other separators In Excel
When you combine the cells from multiple columns or rows into a single cell, the combined data may be separated by nothing. But if you want to separate them with specified marks, such as space, commas, semicolon or others, how can you do? This tutorial will introduce some methods for you.
Concatenate cells keeping number/date formatting in Excel
You may have noticed that when we apply the CONCATENATE function in Excel, the date format (2014-01-03) and number format such as currency format ($734.7), percentage format (48.9%), decimal places (24.5000), etc. are removed and show as general numbers in the concatenation results. In this article we come up with several workarounds to concatenate data with keeping date or number formatting in Excel.
Reverse the concatenate function in Excel
As we all known, the Concatenate function in Excel can help us to combine multiple cells into one cell, but, sometimes, you want to do the opposite of Concatenate function, it means not combine cells, but split cell value into multiple separated cells. Methods in this article will help solve the problem.
Concatenate cells if same value exists in another column in Excel
This article provides methods to help you easily concatenate cells if same value existing in another column in Excel.