Combine Duplicate Rows and Join Corresponding Values in Excel
AuthorXiaoyang•Last modified
When working with large Excel worksheets, duplicate records are very common. For example, the same customer may appear in multiple rows with different products, the same order ID may contain several item names, or the same employee may have multiple project records.
Instead of keeping these duplicate rows separately, you may want to combine them into one row and join the corresponding values into a single cell. This makes your data cleaner, easier to read, and more suitable for reporting or analysis.
This tutorial explains several practical ways to combine duplicate rows and concatenate corresponding values in Excel.

Combine Duplicate Rows and Join Corresponding Values
- Method1: With formulas (Excel 365, Excel 2021 and later versions)
- Method 2: With VBA code
- Method 3: With Kutools for Excel
Combine Duplicate Rows and Join Corresponding Values
For example, if the same department appears multiple times with different employee names, you may want to keep one department row and join all corresponding employees together. Manually copying and merging these values can be time-consuming and easy to get wrong, especially when the dataset is large. Fortunately, Excel offers several ways to handle this task. In this section, we will introduce three practical methods to combine duplicate rows and join corresponding values: using formulas, VBA code, and Kutools for Excel for a quicker visual solution.
Method1: With formulas (Excel 365, Excel 2021 and later versions)
If you are using Excel 365, Excel 2021, or a later version, you can combine duplicate rows by using dynamic array formulas such as UNIQUE, FILTER, and TEXTJOIN. This method is formula-based, so the result can update automatically when the source data changes.
Step 1: Extract Unique Values
First, enter the following formula in a blank cell, then, press Enter key, it will extract the unique department names from the original list. See screenshot:
=UNIQUE(A2:A15)

Step 2: Join Corresponding Values
Next, enter this formula:
=TEXTJOIN(", ",TRUE,FILTER($B$2:$B$15,$A$2:$A$15=D2))
Then drag the formula down to apply it to the other unique departments. See screenshot:

Formula Explanation
- FILTER($B$2:$B$15,$A$2:$A$15=D2) finds all employees that belong to the department in D2.
- TEXTJOIN(", ",TRUE,...) joins the matching employee names together and separates them with commas.
- TRUE tells Excel to ignore empty cells.
Tip: Join Values with Line Breaks
If you want each employee name to appear on a separate line within the same cell, use this formula:
=TEXTJOIN(CHAR(10),TRUE,FILTER($B$2:$B$15,$A$2:$A$15=D2))
Then enable Wrap Text for the result cells.
Pros
- No VBA required.
- The result updates automatically when the source data changes.
- Easy to modify the separator, such as comma, semicolon, or line break.
- Works well for small and medium-sized datasets.
Cons
- Only available in Excel 365, Excel 2021, and later versions.
- The result is formula-based, not static text.
- It may become slower when working with very large datasets.
- Older Excel versions do not support dynamic array functions like UNIQUE and FILTER.
Method 2: With VBA code
If you are using an older version of Excel or want to generate static results, VBA is a useful solution. With VBA, you can combine duplicate rows and join corresponding values automatically.
This method is especially suitable when you need to process data repeatedly or when your Excel version does not support modern dynamic array formulas.
- Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
- Click Insert > Module, and paste the following code in the Module Window.
Sub CombineRows()
Dim WorkRng As Range
Dim Dic As Variant
Dim arr As Variant
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set Dic = CreateObject("Scripting.Dictionary")
arr = WorkRng.Value
For i = 1 To UBound(arr, 1)
xvalue = arr(i, 1)
If Dic.Exists(xvalue) Then
Dic(arr(i, 1)) = Dic(arr(i, 1)) & " " & arr(i, 2)
Else
Dic(arr(i, 1)) = arr(i, 2)
End If
Next
Application.ScreenUpdating = False
WorkRng.ClearContents
WorkRng.Range("A1").Resize(Dic.Count, 1) = Application.WorksheetFunction.Transpose(Dic.keys)
WorkRng.Range("B1").Resize(Dic.Count, 1) = Application.WorksheetFunction.Transpose(Dic.items)
Application.ScreenUpdating = True
End Sub
- Then press F5 key, and a prompt box pops out to remind you to select a range that you need to combine. See screenshot:

- And then click OK, the values in column B have been combined into one record and separated by spaces. See screenshot:

Tip: Join Values with other separator
In the VBA code, this part controls the separator:
Dic(arr(i, 1)) = Dic(arr(i, 1)) & " " & arr(i, 2)
For example, to separate values with a semicolon, change it to:
Dic(arr(i, 1)) = Dic(arr(i, 1)) & "; " & arr(i, 2)
To separate values with a line break, use:
Dic(arr(i, 1)) = Dic(arr(i, 1)) & vbLf & arr(i, 2)
Then enable Wrap Text in the result cells.
Pros
- Works in older Excel versions.
- Produces static results.
- Suitable for repeated tasks.
Cons
- Requires basic VBA knowledge.
- Macros must be enabled before running the code.
- The result is static and will not update automatically when the source data changes.
- This code may overwrite or modify the original data. To avoid data loss, it is strongly recommended to back up your worksheet before running the code.
- This code is intended for two-column data only. Additional columns will not be processed and may be overwritten or lost.
Method 3: With Kutools for Excel
If you prefer a visual and easier way to combine duplicate rows, Kutools for Excel provides a convenient feature that can merge rows based on duplicate values and combine the corresponding contents without writing formulas or VBA code.
This method is suitable for users who want to quickly process duplicate records through a dialog box.
- Select the data range that contains duplicate rows.
- Click Kutools > Merge & Split > Advanced Combine Rows.
- In the Advanced Combine Rows dialog box:
- Select the column that contains duplicate values, such as Department, set this column as the key column.
- Select the column that contains the values you want to join, such as Employee. And then, choose one combine option from the Combine group, such as Comma, Colon, Semicolon, Space, Nothing, or New line.
- Click OK to apply the settings and combine duplicate rows.

Tip:
If needed, you can also check other options, such as:
- Use formatted values: combine values based on their displayed formatting.
- Skip empty cells: ignore blank cells when combining values.
- Delete duplicate values: remove repeated values in the combined result.
Kutools will combine rows with the same department and join the related employee names into one cell. See screenshot:

Combine Duplicate Rows Faster with Kutools for Excel
Kutools for Excel provides a visual and flexible way to combine duplicate rows without formulas, VBA. Just select the key column, choose how to merge the related values, preview the result, and click OK.
Easy Visual Operation
Combine duplicate records through a dialog box instead of writing complex formulas or running macros.
Flexible Combine Options
Join values with commas, semicolons, spaces, line breaks, or no separator, and remove duplicate joined values if needed.
More Than Text Joining
Besides combining text, you can also sum, count, average, keep the first or last value, and more.
Tips for Combining Duplicate Rows Correctly
1. Make a Backup Before Processing Data
Before combining duplicate rows, it is always a good idea to make a copy of your worksheet. This is especially important when you use VBA or tools that directly change the original data.
2. Check for Extra Spaces
Duplicate values may not be recognized correctly if some cells contain leading or trailing spaces.
3. Choose the right separator
Use commas for short lists, semicolons for clearer separation, or line breaks when the joined values are long.
4. Check Blank Cells
If some corresponding value cells are blank, decide whether you want to ignore them or include them in the final result. In most cases, blank cells should be ignored to keep the combined result clean.
Conclusion
Combining duplicate rows and joining corresponding values is a common task when cleaning and summarizing Excel data.
- If you are using Excel 365 or Excel 2021, formulas such as UNIQUE, FILTER, and TEXTJOIN provide a flexible and dynamic solution.
- If you are using an older Excel version or want static results, VBA can help automate the process efficiently.
- For users who prefer a simple visual operation without formulas or code, Kutools for Excel offers an easier way to merge duplicate rows and combine related values.
In short, the best method depends on your Excel version, data size, and whether you want the result to update automatically. For modern Excel users, formulas are a great first choice. For repeated or large-scale data processing, VBA and Kutools can save more time and reduce manual work.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
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!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.
- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in
Table of contents
- Combine Duplicate Rows and Join Corresponding Values
- Method1: With formulas
- Method 2: With VBA code
- Method 3: With Kutools for Excel
- Tips for Combining Duplicate Rows Correctly
- Conclusion
- The Best Office Productivity Tools
Kutools for Excel
Brings 300+ advanced features to Excel
- ⬇️ Free Download
- 🛒 Purchase Now
- 📘 Feature Tutorials
- 🎁 30-Day Free Trial