In Excel, merging multiple rows, columns or cells is a common task. However, the fundamental problem in this task is that it only keeps data from the upper left cell. This limitation becomes critical when dealing with crucial data management tasks such as financial records or customer details.
In this Excel tutorial, you will learn to merge rows without losing data by using Excel functions, copy-paste commands, ampersand operator, notepad, and VBA code.
Consider a dataset with customer names in rows 6 to 12. Our task is to merge these rows and gather all the customer names into a single row.
Here are 5 methods to merge rows without losing data in Excel:
Using Excel Functions
To merge rows without losing data in Excel, use Excel functions like TEXTJOIN, CONCAT, or CONCATENATE. Although it’s an indirect approach, these functions ensure the merging of row data without losing any valuable information.
1. Using TEXTJOIN Function
The TEXTJOIN function concatenates text from multiple cells, ranges, or columns in Excel. It is designed to work with range eliminating the need for manual cell input. Additionally, using the TEXTJOIN function, you can also handle blank cells and add separators when merging data from multiple rows. You will find this function in Excel 2016 and later versions.
To merge rows without losing data in Excel using the TEXTJOIN function, follow these steps:
- Select a blank cell.
- Write the following formula:
=TEXTJOIN(", ",TRUE,B6:B12)
To keep all values in just one cell, you will have to apply Wrap Text. - Select the output cell and then go to the Home tab > Alignment group >Â Warp Text.
In the output, you will notice a comma (,) and a space which act as a separator here while merging row values.
2. Using CONCAT Function
The CONCAT function in Excel also merges text from multiple cells into a single cell. The drawback of the CONCAT function is it doesn’t handle empty cells and errors well. Moreover, you need to manually input the rows.
To merge rows without losing data in Excel using the CONCAT function, follow these steps:
- Select a blank cell.
- Write the following formula:
=CONCAT(B6,", ",B7,", ",B8,", ",B9,", ",B10,", ",B11,", ",B12)
- Go to the Home tab > Alignment group > Warp Text.
It is recommended to use data separators (comma and space) in the formula or else the output may become difficult to understand.
- The CONCAT function is an alternative to the CONCATENATE function. You can also use the CONCATENATE function to merge rows without losing data in Excel. Here is the formula:
=CONCATENATE(B6,", ",B7,", ",B8,", ",B9,", ",B10,", ",B11,", ",B12)
- The CONCAT function is recommended for its simplicity and compatibility across all Excel versions.
- While using the CONCAT function, specify each cell individually.
Read more: How to Merge Rows and Columns in ExcelÂ
Using Copy and Paste Command
The copy and paste command in Excel is handy for moving information around. It helps to transfer data between different places in Excel or even between different applications.
To use the copy and paste command for merging rows in Excel without losing data, follow these steps:
- Select data.
- Go to Home tab > Clipboard group > Copy
or you can press CTRL+C.
- Select the output cell using double click.
- Click the Clipboard icon from the Home tab. It will open the Clipboard panel at the left.
- Select the Paste All option.
It will return the following final output.
Read more: How to Merge Rows in Excel Based on Criteria
Using Ampersand Operator
The Ampersand (&) operator is very useful for combining text, numbers, or cell references in Excel. You can also use the ampersand operator to create a dynamic formula.
To merge rows without losing data in Excel using the Ampersand operator, follow these steps:
- Select a blank cell.
- Write the following formula
=B4&", "&B5&", "&B6&", "&B7&", "&B8&", "&B9&", "&B10
- Press Enter.
The final output will look like the following image.
Read More: How to Combine Multiple Rows into One Cell in Excel
Using Notepad
You can also merge multiple rows into a single row by using Notepad. Although it is not a conventional approach, this method can help in the case of large datasets. Notepad eliminates any formatting complexities present in Excel. Here are the steps:
- Select data from all the rows and press CTRL+C.
- Then, paste the data into an empty Notepad.
You can customize data in the notepad easily. For example, you can put all the names in one line, or you can insert a comma between two names. - After that, copy and paste it back into an empty row of your Excel file by using double click.
Applying VBA Code
To save time and effort, in the case of a large dataset, it is very helpful to use VBA code to merge rows while preserving existing data.
Check the following steps to apply VBA code to merge rows without losing data in Excel.
- Go to the Developer tab > Visual Basic.
Or you can press ATL+F11.
It will open the Microsoft Visual Basic Application window. - Now go to the Insert tab > Module.
- Copy and paste the following code into the module.
Sub vba_merge_with_values() Dim val As String Dim rng As Range Set rng = Selection For Each Cell In rng val = val & " " & Cell.Value Next Cell With rng .Merge .Value = Trim(val) .WrapText = True .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter End With End Sub
- Click Save or you can press CTRL+S as the keyboard shortcut.
- Next, select the rows and go to the Developer tab > Code group > Macros.
- From the Macro dialogue box, select the code and press Run.
- A warning message will pop up. Click OK to proceed.
You will have the following output after using the code.
Download Practice Workbook
You can download the workbook to practice yourself.
Conclusion
Merging rows or columns in Excel is a basic skill. It is important to learn how to merge rows without losing any data due to the technical complexity associated with this feature. To merge data from different rows into a single row, you can make use of Excel functions or the ampersand operator within a formula. Another useful shortcut in this regard is using copy and paste command. Additionally, the VBA code can be of great assistance for large sheet. All these methods can help you to manage your data efficiently. If you have any suggestions or queries, feel free to ask in the comment section below.
Frequently Asked Questions
How Do I Convert Multiple Rows to One Column in Excel?
To convert multiple rows to one column in Excel, follow these steps:
- Select the rows.
- Copy the selected rows or use CTRL+C.
- Choose the output cell.
- Right-click on the selected cell and choose Paste Special.
- In the Paste Special dialog box, select Transpose and click OK.
This will convert the data from multiple rows into one column.
How to Handle Blank Cells During the Merging Process?
To handle blank cells during the merging process, use the TEXTJOIN function which provides the option to include or ignore blank or empty cells in a range.
How to Merge Rows With Different Data Types Without Losing Information?
To merge rows with different data types in Excel, use Excel functions like CONCAT, CONCATENATE, and TEXTJOIN. It allows you to combine data from various cells while preserving the integrity of different data types.
Further Readings
- Convert Multiple Rows to A Single Column in Excel
- How to Convert Multiple Rows to Single Row in Excel
- Excel Combine Rows with Same ID
- How to Merge Two Rows in Excel
- How to Merge Rows with Comma in Excel
- How to Merge Rows with Same Value in Excel
<< Go Back to Merge Rows in Excel | Merge in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!
Thank You! This helps a lot!