How to merge rows in Excel without losing data
By the Analistable team · Updated · 2 min read
Excel's Merge Cells keeps only the top value, so merge the contents instead. To put the text of several rows into one cell, use =TEXTJOIN(CHAR(10), TRUE, A2:A6) and turn on Wrap Text. For a column of short text lines, Home → Fill → Justify joins them into the top cell. If the rows share a key (the same customer on several rows), consolidate them with a pivot table, SUMIFS or Power Query Group By.
Part of our guide: How to consolidate data in Excel
What kind of row merge do you need?
| You have | You want | Method |
|---|---|---|
| An address split over 4 rows | One cell with the whole address | TEXTJOIN with line breaks |
| Short lines of text in one column | One paragraph | Fill → Justify |
| Several rows per customer | One row per customer with totals | Consolidate (pivot, SUMIFS, Group By) |
| Two rows that describe the same record | One complete row | Take the non-empty value per column |
Join several rows into one cell
=TEXTJOIN(CHAR(10), TRUE, A2:A5)CHAR(10) is a line break; turn on Home → Wrap Text to see the lines. Use ", " instead for a comma-separated list. TRUE skips empty cells. Then copy the cell and Paste Special → Values before deleting the original rows.
| Cell | Value |
|---|---|
| A2 | 12 Rue Victor Hugo |
| A3 | Apt 3 |
| A4 | 69002 Lyon |
| A5 | France |
| B2 =TEXTJOIN(CHAR(10),TRUE,A2:A5) | 12 Rue Victor Hugo ↵ Apt 3 ↵ 69002 Lyon ↵ France |
Fill → Justify for text blocks
- Make the column wide enough to hold the combined text.
- Select the cells to join (one column, text only).
- Choose Home → Fill → Justify.
Excel joins the text into as few cells as the column width allows, starting at the top. It's quick for notes or descriptions pasted across several rows. It works on text only (not numbers or formulas) and on up to 255 characters per cell.
Merge two partial rows into one complete row
When two rows describe the same record with different columns filled in, take the first non-blank value in each column. For rows 2 and 3:
=IF(B2<>"", B2, B3)For many records, Power Query does it per key: Group By the ID with All Rows, then for each column use List.First(List.RemoveNulls([Column])).
Consolidate rows that share a key
One row per customer with totals is a consolidation: use a pivot table, =SUMIFS() next to a =UNIQUE() list, or Power Query Group By. To keep the text from those rows too, use TEXTJOIN with FILTER. Full walkthrough: combining duplicate rows in Excel.
Merging rows *across sheets* (stacking) is a different task — see combining Excel sheets into one.
Frequently asked questions
- How do I merge two rows in Excel without losing data?
- Join their contents with a formula such as =TEXTJOIN(" ", TRUE, A2:A3) or =IF(B2<>"", B2, B3) per column, paste the result as values, then delete the extra row.
- Why does Merge Cells delete my data?
- Excel keeps only the upper-left value when merging cells. Combine the contents with a formula first.
- How do I combine rows with the same ID?
- Use a pivot table or SUMIFS for numbers, and TEXTJOIN with FILTER (or Power Query Group By) for text.