Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Merging Rows: Combine Data Without Losing It

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step: Merging Cells (Visual Merge)
  3. Step-by-Step: Combining Text from Multiple Rows into One Row
  4. Common Mistakes
  5. Tips
  6. Troubleshooting
  7. Frequently Asked Questions

Merging rows in Excel can mean two very different things: merging cells so multiple rows become one visual block (great for headers), or combining the text/values from several rows into a single row (essential for cleaning up data). This guide covers both, with the exact steps for each, plus what to do when things don't work as expected. You don't need any special add-ins or macros—just a standard copy of Excel (2016 or later, including Microsoft 365) and your data ready to go.

What You'll Need

  • A computer with Excel installed (desktop version recommended; steps for Excel for the web are noted where they differ).
  • Your data in a worksheet, ideally with no completely empty rows or columns in the range you're working with.
  • If you plan to combine text from multiple rows into one, a blank column to the right of your data (or a spare area) where you can put a formula or use the Flash Fill feature.

Before you start, make a backup copy of your workbook (File > Save As > give it a new name). Some actions, like merging cells, can only be undone with Ctrl+Z if you do it immediately; a backup is your safety net.

Step-by-Step: Merging Cells (Visual Merge)

This is the simplest kind of merge—it combines two or more cells into one larger cell. It's perfect for making a title span across columns or grouping a label over several rows. Note that this only keeps the upper-left cell's content; any other selected cells' values will be deleted.

  1. Select the cells you want to merge. They must be adjacent (touching) and form a rectangle. For example, select A1:A5 to merge five rows into one.
  2. Go to the Home tab on the ribbon.
  3. In the Alignment group, click the Merge & Center button (it looks like two arrows pointing inward). This merges the cells and centers the text.
  4. If you don't want the text centered, click the small arrow next to Merge & Center and choose Merge Across (merges each row separately) or Merge Cells (merges without centering).
  5. If you change your mind, select the merged cell, click the arrow next to Merge & Center, and choose Unmerge Cells.

Important: Merging cells can break sorting, filtering, and some formulas. If you're merging rows that contain data you need to keep, use the text-combining method below instead.

Step-by-Step: Combining Text from Multiple Rows into One Row

This is what most people mean by "merging rows"—taking the values from several rows and putting them into a single cell, often separated by commas or spaces. Here are three reliable ways to do it.

Method 1: Using the TEXTJOIN Function (Excel 2019 and later, Microsoft 365)

  1. In a blank cell where you want the combined result, type =TEXTJOIN(", ", TRUE, A2:A10). Replace A2:A10 with the actual range of rows you want to combine.
  2. Press Enter. The cell will show all the values from A2 to A10, separated by a comma and a space.
  3. The TRUE argument tells Excel to ignore empty cells. If you want to include them as blanks, use FALSE.
  4. You can also use TEXTJOIN with a range that spans multiple columns, like =TEXTJOIN(" ", TRUE, A2:C10), which reads row by row.

Method 2: Using the CONCAT or & Operator (All Versions)

  1. If you don't have TEXTJOIN, you can use the older CONCATENATE function or the & operator. For example, to combine A2, A3, and A4 with a comma and space, type: =A2 & ", " & A3 & ", " & A4.
  2. This gets tedious for many rows. A faster way is to use the CONCAT function (available in Excel 2016 and later) which can take a range: =CONCAT(A2:A10)—but note that CONCAT does not add any separators; it just strings the values together with no spaces.
  3. If you need separators and don't have TEXTJOIN, you can create a helper column. In a new column next to your data, type a formula like =A2 & ", " and drag it down. Then use CONCAT on that helper column, and trim the trailing comma with =LEFT(C2, LEN(C2)-2) if needed.

Method 3: Using Flash Fill (Quick, No Formulas)

  1. In the cell next to your first row of data, manually type the combined result you want for that first row. For example, if A2 is "John" and B2 is "Smith", type "John Smith" in C2.
  2. Press Enter, then start typing the next row's combined value in C3. As you type, Excel will suggest a pattern (grayed-out text).
  3. Press Enter to accept the suggestion. Flash Fill will fill the rest of the column.
  4. If Flash Fill doesn't trigger automatically, go to the Data tab and click Flash Fill (or press Ctrl+E).

Flash Fill works best when your data follows a clear, consistent pattern. It's not a formula, so if you change the original data, the combined cell won't update automatically.

Common Mistakes

  • Losing data when merging cells: The classic error—selecting multiple cells and hitting Merge & Center only keeps the upper-left value. Always copy the data elsewhere first if you need it.
  • Using CONCAT when you need separators: CONCAT simply joins values with no delimiter, so "JohnSmith" instead of "John Smith". Use TEXTJOIN or the & operator with explicit separators.
  • Merging cells in a table: If your data is formatted as an Excel Table (Insert > Table), you cannot merge cells within the table. You'll need to convert it back to a range (Table Design > Convert to Range) first.
  • Not accounting for hidden rows: If you have filtered or hidden rows, TEXTJOIN and CONCAT will include them. Use the SUBTOTAL function or a different approach if you need to skip hidden rows.

Tips

  • Use TEXTJOIN with a line break: Instead of a comma, you can use =TEXTJOIN(CHAR(10), TRUE, A2:A10) to put each value on a new line within the cell. Make sure Wrap Text is enabled (Home > Wrap Text).
  • Keep the original data intact: Instead of merging cells, consider using a formula in a separate column. That way you can sort and filter your data without breaking anything.
  • For merging entire rows (not just cells): If you want to combine all columns of two rows into one row, you can use the & operator in each column. For example, in C1: =A1 & " " & A2, then drag across.
  • Use Power Query for large datasets: If you're combining hundreds of rows, Power Query (Get & Transform) has a "Group By" feature that can concatenate text. It's more advanced but worth learning for heavy data cleaning.

Troubleshooting

If the merged cell only shows the first value: That's by design. Undo with Ctrl+Z, then use the TEXTJOIN method instead.

If TEXTJOIN returns a #NAME? error: Your Excel version doesn't support TEXTJOIN (it's only in Excel 2019, 2021, or Microsoft 365). Use CONCAT or the & operator with a helper column.

If Flash Fill doesn't work: Make sure you're typing the pattern in a column that's directly adjacent to your data. Also, ensure there are no blank rows between the data and your typed example. Try selecting the cell and pressing Ctrl+E manually.

If merging cells breaks your formulas: Merged cells can cause #SPILL! errors or make VLOOKUP fail. Avoid merging cells that are referenced in formulas. Instead, use Center Across Selection (select the cells, right-click > Format Cells > Alignment > Horizontal > Center Across Selection) which visually centers text without actually merging.

If you get a warning about losing data when merging: Excel will show a dialog saying "Merging cells only keeps the upper-left value." Click Cancel, then use the text-combining method to preserve all data.

Frequently Asked Questions

Can I merge rows without losing data?

Yes, use the TEXTJOIN function or the & operator to combine the values into a new cell. The original rows remain untouched.

How do I merge rows in Excel for the web?

Excel for the web supports Merge & Center in the Home tab, and it also supports TEXTJOIN and CONCAT. Flash Fill is not available in the web version, so use formulas there.

What's the difference between merging cells and combining text?

Merging cells physically joins cells into one, keeping only the upper-left value. Combining text uses a formula to concatenate values from multiple cells into a single cell, which can be placed anywhere.

Can I unmerge cells after merging?

Yes, select the merged cell, go to Home > Merge & Center (or the arrow next to it) and choose Unmerge Cells. However, you cannot recover the data that was lost during the original merge—only the upper-left value remains.

Why does CONCAT not add spaces?

CONCAT is designed to join text exactly as-is without any delimiter. You need to include separators manually, either by adding them as extra arguments (like =CONCAT(A2, " ", B2)) or using TEXTJOIN which has a delimiter argument.

Is there a way to merge rows based on a common column?

Yes, that's a more advanced task. Use Power Query's Group By feature, or create a pivot table. For a simple approach, sort by the common column, then use TEXTJOIN with a helper column that groups rows—but that's manual. Power Query is the reliable method.