We’ve got a dataset with the Product ID and Product Name of some products of a company named Mars Group. The values are stored in the Cell range B5:C9. We’ll concatenate the names of all the products in a single cell.
Method 1 – Combine CONCATENATE and TRANSPOSE Functions to Concatenate a Range
- Select Cell B12 and insert this formula.
=CONCATENATE(TRANSPOSE(C5:C9&",")
- Select TRANSPOSE(C5:C9&”,” from the formula and press F9 on your keyboard.
- The formula will convert into values like this.
- Remove the Curly Brackets from both sides.
- Press Enter and you will see the required output.
Method 2 – Concatenate a Range with TEXTJOIN Function in Excel
The TEXTJOIN function is available only in Office 365.
- Select Cell B12 and insert this formula.
=TEXTJOIN(",",TRUE,C5:C9)
- Press Enter.
Method 3 – Apply Excel VBA to Concatenate a Range
- Press Alt + F11 on your keyboard to open the Microsoft Visual Basic for Applications window.
- Select Module from the Insert tab.
- Insert this code inside the blank page.
Function TEXTJOIN2(delimiter As Variant, ignore_blank As Variant, range As Variant)
Dim i As Variant
Dim j As Variant
Dim out As Variant
out = ""
If ignore_blank = False Then
For i = 1 To range.Rows.Count
For j = 1 To range.Columns.Count
If i = range.Rows.Count And j = range.Columns.Count Then
out = out + range(i, j)
Else
out = out + range(i, j) + delimiter
End If
Next j
Next i
Else
For i = 1 To range.Rows.Count
For j = 1 To range.Columns.Count
If range(i, j) <> "" And i = range.Rows.Count And j = range.Columns.Count Then
out = out + range(i, j)
ElseIf range(i, j) <> "" Then
out = out + range(i, j) + delimiter
End If
Next j
Next i
End If
TEXTJOIN2 = out
End Function
- Press Ctrl + S to save the code and close the window.
The code generates the TEXTJOIN2 function with the following syntax.
- Use the formula in Cell B12.
=TEXTJOIN2(", ",TRUE,C5:C9)
- The formula will concatenate the Product Names into a single cell.
Method 4 – Concatenate a Range with Power Query in Excel
- Select Cell range C4:C9.
- Go to the Data tab and select From Table/Range under the Get & Transform Data.
- You will get the Create Table window with a preselected range.
- Check the My table has headers box and press OK.
- You will get the Power Query Editor window.
- Select the strings column and go to the Transform tab.
- Select Transpose from the Table group.
- Select all the separated columns in the window by pressing the Ctrl button on your keyboard and right–click on any of them.
- Click on Merge Columns.
- Choose Comma as the Separator in the Merge Columns dialogue box.
- Type List of Products in the New column name section.
- Select Close & Load from the Home tab.
- You will get the range in a new worksheet like this.
Read More: How to Concatenate Two Columns in Excel
Method 5 – Use Fill Justify to Concatenate a Range
- Select Cell range C5:C9.
- Go to the Home tab and click on Fill under the Editing group.
- Select Justify from the drop-down menu.
- You will get the concatenated array from the single array.
Download the Practice Workbook
Excel Concatenate Range: Knowledge Hub
- How to Concatenate Rows in Excel
- How to Concatenate Rows in Excel with Comma
- How to Concatenate Two Columns in Excel with Hyphen
- How to Combine Multiple Columns into One Column in Excel
- How to Concatenate Arrays in Excel
<< Go Back to Concatenate | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!