To solve this problem, maybe the following article can help you, please check it:
https://www.extendoffice.com/documents/excel/2723-excel-concatenate-based-on-criteria.html
When you combine the cells from multiple columns or rows into a single cell, the combined data may be separated by nothing. But if you want to separate them with specified marks, such as space, commas, semicolon or others, how can you do? This tutorial will introduce some methods for you.
In Excel, you can use the below formulas to combine a row of cells or a column of cells into a single cell.
In Excel, you can use the "&" operator to combine different text strings or cell values.
Please enter the below formula to concatenate the cells in multiple columns: (separate the combined results with space, you can replace the blank with other separators as you need.)
And then, drag the fill handle down to the cells that you want to apply this formula, and the data from different columns have been merged into one cell, see screenshot:
The Concatenate function in Excel is also used to join multiple text strings or cell values into one cell.
Please enter or copy the below formula into a blank cell:
And then, drag the fill handle down to the cells that you want to apply this formula, you will get the following result:
If you have Excel 365 and later versions, there is new function-Textjoin, this function also can help you to combine multiple cells into one cell.
Enter or copy the following formula into a blank cell:
Then, drag the fill handle to apply this formula to other cells, see screenshot:
Concatenate row, column or range of cells into one cell with a specified separator
Kutools for Excel supports a powerful feature-Combine which can help you to merge all data based on rows, columns or a range of cells into one record without losing data. Please see the below demo. Click to download Kutools for Excel!
In Excel, you can also create a User Defined Function to combine cells of row or column into a single cell with spaces or specified marks.
1. Hold ALT + F11 keys on the keyboard to open a Microsoft Visual Basic for Application window.
2. Click Insert > Module, and copy the VBA into the module.
VBA: Combine cells based on row or column into one with specific separator:
Function Combine(WorkRng As Range, Optional Sign As String = "~") As String Dim Rng As Range Dim OutStr As String For Each Rng In WorkRng If Rng.Text <> " " Then OutStr = OutStr & Rng.Text & Sign End If Next Combine = Left(OutStr, Len(OutStr) - 1) End Function
Tip: In the above script "Function Combine(WorkRng As Range, Optional Sign As String = "~") As String", the separator "~" is specified to separate the combined result, you can change it to meet your need.
3. Then please type formula =Combine(A2:C2) in a blank cell, and then drag the fill handle over the range that you want to apply this formula, all of the cells in the row will be combined into a cell with dashes. See screenshot:
Tips: With above User Defined Function, you can also combine cell values based on column, you just need to enter this formula =Combine(A2:A7) to get the merged data as you need.
Sometimes, you may want to use the line break to separate the concatenated text string, normally, the CHAR(10) will return the line break character. Here, you can use the below methods to solve this task:
Here, you can combine the concatenate function with the Char(10) character together to get the merged result which is separated by line break.
1. Please type or copy the below formula:
Then, drag the fill handle down to the cells you want to apply this formula, and you will get the following result:
2. Then, you should click Home > Wrap Text to format the cells, and then, you will get the result as you need:
Tips: To combine the cell values from multiple rows, you just need to change the cell reference as this: =CONCATENATE(A2,CHAR(10),A3,CHAR(10),A4,CHAR(10),A5,CHAR(10),A6,CHAR(10),A7)
May be the above formula is somewhat difficult if there are multiple cells needed to be combined, so, the Textjoin function can deal with this task quickly and easily.
Please enter or copy the below formula into a blank cell:
After getting the combined results, please remember to format the formula cells to Wrap Text, see screenshot:
Tips: To combine the cell values from multiple rows, you just need to change the cell reference as this: =TEXTJOIN(CHAR(10),TRUE,A2:A7)
If you are annoying with the above formulas and code, here, I can recommend a useful tool- Kutools for Excel, with its Combine feature, you can quickly combine cell values by row, column or a range into one single cell.
Tips:To apply this Combine feature, firstly, you should download the Kutools for Excel, and then apply the feature quickly and easily.
After installing Kutools for Excel, please do as this:
1. Select a range cell values that you want to combine into a cell.
2. Please apply this function by clicking Kutools > Merge & Split > Combine Rows, Columns or Cells without Losing Data. See screenshot:
3. In the popped out dialog box, please specify the operations you need as following screenshot shown:
4. Then, click Ok, you will get the result as below screenshot shown:
1). Combine cell values into one cell for each row:
2). Combine cell values into one cell for each column:
3). combine a range of cell values into one single cell:
![]() |
![]() |
![]() |
Click to Download Kutools for Excel and free trial Now!