How to merge duplicate rows in excel
Tutor 5 (73 Reviews)
Excel Tutor
Still stuck with a Excel question
Ask this expertAnswer
Merging duplicate rows in Excel involves combining rows that have the same values in one or more columns while preserving unique information in other columns. This process is useful when cleaning data, summarizing information, or preparing reports.
Method 1: Using Remove Duplicates (Simplest Approach)
To eliminate duplicate rows:
-
Select the range of data where duplicates exist.
-
Go to the Data tab on the Ribbon.
-
Click Remove Duplicates.
-
In the dialog box, check the columns you want to compare for duplicates.
-
Click OK.
Note: This method deletes the duplicate rows completely. Unique data in other columns may be lost.
Method 2: Using Consolidate to Merge Values
To combine values from duplicate rows without losing data:
-
Select an empty cell where you want the merged data to appear.
-
Go to the Data tab and click Consolidate.
-
Choose a function like Sum, Average, or Count depending on how you want to merge.
-
In Reference, select the data range.
-
Check Top row and Left column if your data has headers.
-
Click OK.
This method creates a summary table combining duplicate row values mathematically.
Method 3: Using Power Query to Merge Duplicate Rows
Power Query is ideal for complex data merging:
-
Select the data range and go to Data → Get & Transform Data → From Table/Range.
-
In the Power Query editor, select the column(s) identifying duplicates.
-
Click Group By on the Home tab.
-
In the dialog box:
-
Group By: The column(s) with duplicates.
-
Operation: Choose All Rows, Sum, Count, or Text.Combine for text columns.
-
-
Click OK and then Close & Load to return the merged table to Excel.
Example:
If two rows have the same "Product ID," you can merge their sales numbers using Sum and combine comments using Text.Combine.
Method 4: Using Formulas to Merge Duplicate Rows
To merge duplicates while keeping all text in one cell:
-
Use the TEXTJOIN formula with IF and FILTER.
-
Suppose
A2:A10contains duplicate IDs andB2:B10contains values:=TEXTJOIN(", ", TRUE, IF(A2=$A$2:$A$10, $B$2:$B$10, ""))
-
Press Ctrl + Shift + Enter in older versions of Excel (array formula).
-
The result combines all values from duplicate rows into a single cell.
Explanation: TEXTJOIN merges text, IF filters rows matching the duplicate, and TRUE ignores empty cells.
Key Considerations
-
Back up your data before merging duplicates.
-
Decide whether to preserve unique information or summarize it.
-
Choose formulas for dynamic merging that update automatically when new data is added.
-
Power Query is recommended for large datasets due to speed and flexibility.
Get Online Tutoring or Questions answered by Experts.
You can post a question for a tutor or set up a tutoring session
Answers · 1
How to show duplicates in red
Answers · 1
How to apply duplicate conditional formatting rule
Answers · 1
How to duplicate conditional formatting excel
Answers · 1
What is excel conditional formatting duplicates
Answers · 1