Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to join texts in a column without duplicates in Excel?

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…


Join texts in a column without duplicates with formula

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.


Join texts in a column without duplicates based on another cell value with VBA code

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.


Easily join texts in a column based on another cell value with an amazing tool

Maybe you are not good at formula or VBA code. Here recommend the Advanced Combine Rows utility of Kutools for Excel for you. With this utility, you can easily join texts in a column based on value in another cell with only several clicks.

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:

  • Select the column containing the values you will join texts based on, and click Primary Key;
  • Select the column containing the texts you will join into a cell, and click Combine > Comma;
  • If there are columns left, please specify conditions for them. In this case, I select the Sales column and select Calculate > Sum.
  • Click the OK button. See screenshot:

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.


Related articles

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.

More tutorial for combining cells…


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.