How to Concatenate Rows in Excel (11 Methods)

Concatenate means to merge or combine two or more cells’ contents into a single cell.


Method 1 – Applying Ampersand(&) Operator to Concatenate Rows in Excel

You can concatenate strings using Ampersand (&). The advantage of using the Ampersand operator is that there is no limit for allowable strings to join.

Steps:

  • Type the below formula in Cell C5.
=B5&" "&B6&" "&B7&" "&B8&" "&B9

Apply ‘&’ Operator to Combine Rows in Excel

  • Hit Enter and the texts from 5 rows are joined.


Method 2 – Using Excel IF Function and ‘&’ Operator to Concatenate Rows

The IF function can be used in conjunction with the ‘&’ operator to concatenate rows. The sample dataset contains the fruits type in column B and related fruit names are listed in column C.

 

Use Excel IF function and ‘&’ Operator to Concatenate Rows

Steps:

  • Type the below formula in Cell D5 and hit Enter.
=IF(B5=B4,D4&","&C5,C5)

Use Excel IF function and ‘&’ Operator to Concatenate Rows

  • Use the Fill Handle (+) tool to copy the formula to the range D5:D10.

Use Excel IF function and ‘&’ Operator to Concatenate Rows

  • A growing list of fruit names to their corresponding fruit type is returned.

Use Excel IF function and ‘&’ Operator to Concatenate Rows

  • This is not the final result. As the dataset is sorted alphabetically according to fruit type, the cell containing the most text will be the desired result.
  • To find the cell with the most text, type the below formula in Cell E5.
=IF(B5<>B6,"Last","")

Use Excel IF function and ‘&’ Operator to Concatenate Rows

  • Press Enter and use the Fill Handle tool to copy the formula to the rest of the cells which returns the below result; ‘Last’ is assigned to the longest concatenated texts.

 

Related Content: How to Combine Multiple Rows into One Cell in Excel


Method 3 – Inserting Excel CONCATENATE Function to Combine Rows

Use the CONCATENATE function to join excel rows.

Steps:

  • Type the following formula in Cell C5.
=CONCATENATE(B5," ",B6," ",B7," ",B8," ",B9)

Insert CONCATENATE Function to Combine Rows in Excel

  • Press Enter.


Method 4 – Using CONCAT Function to Combine Rows in Excel

In Excel 365 and Excel 2019, you can use the CONCAT function to combine text from a range spread over different rows.

Steps:

  • Type the below formula in Cell C5 to join text from the range B5:B7.
=CONCAT(B5:B7)

Excel CONCAT Function to Combine Rows

  • Press Enter.


Method 5 – Applying Excel TEXTJOIN Function to Join Rows

Steps:

  • Type the following formula in Cell C5.
=TEXTJOIN(" ",TRUE,B5:B9)

Excel TEXTJOIN Function to Join Rows

  • Hit Enter.


Method 6 – Joining TRANSPOSE and CONCATENATE Functions to Add Rows

Combine the TRANSPOSE function along with the CONCATENATE function to get a joined text from selected rows.

Steps:

  • Type the below formula in Cell C5 but do not press Enter.
=TRANSPOSE(B5:B7)

TRANSPOSE  and CONCATENATE Functions to Concatenate Rows

  • Put the cursor on the above formula and press F9 from the keyboard. The formula will look like the below image. Remove both of the curly brackets from the formula.

TRANSPOSE  and CONCATENATE Functions to Concatenate Rows

  • After deleting the curly brackets, type CONCATENATE before the first value and close the formula with parentheses. The formula looks like below:
=CONCATENATE(221,"Baker","Street")

TRANSPOSE  and CONCATENATE Functions to Concatenate Rows

  • Press Enter.

Related Content: Opposite of Concatenate in Excel (4 Options)


Method 7 – Merging Excel IF and TEXTJOIN Functions to Concatenate Multiple Rows

Use IF and TEXTJOIN functions to combine strings from rows.

In the sample dataset (B5:C10) contains fruit types in column B and fruit names in column C.

We can combine all the fruit names in a fruit type category and concatenate the result.

IF and TEXTJOIN Functions to Concatenate Multiple Rows in Excel

Steps:

  • Type the below formula in Cell D5 and press Enter.
=IF(B5="","",TEXTJOIN(", ",TRUE,C5:C7))

IF and TEXTJOIN Functions to Concatenate Multiple Rows in Excel

  • Use the Fill Handle to copy the formula to the rest of the cells.

IF and TEXTJOIN Functions to Concatenate Multiple Rows in Excel

  • All the fruits under a certain category are concatenated as below.

Related Content: How to Concatenate Multiple Cells in Excel (8 Quick Approaches)


Method 8 – Combining TEXTJOIN, OFFSET, and COUNTIF  Functions to Add Rows

Combine TEXTJOIN, OFFSET, COUNTIF, and IF functions to join rows in Excel.

The sample dataset contains fruit types and fruit names. We can merge the fruits according to their type.

Combination of TEXTJOIN, OFFSET, and COUNTIF  Functions to Concatenate Rows in Excel

Steps:

  • Type the below formula in Cell D5 and press Enter.
=IF(B5=B4,"",TEXTJOIN(", ",TRUE,OFFSET(C5,0,0,COUNTIF(B:B,B5),1)))

Combination of TEXTJOIN, OFFSET, and COUNTIF  Functions to Concatenate Rows in Excel

  • Use the Fill Handle to copy the formula to the rest of the cells.

How Does the Formula Work?

 COUNTIF(B:B,B5)

This part of the formula returns:

{3}

OFFSET(C5,0,0,COUNTIF(B:B,B5),1)

This part returns:

{$C$5:$C$7}

TEXTJOIN(“, “,TRUE,C$5:$C$7)

This part returns:

{Lemon,Orange,Lime}

IF(B5=B4,””,TEXTJOIN(“, “,TRUE,OFFSET(C5,0,0,COUNTIF(B:B,B5),1)))

Applying the B5=B4 condition returns:

{Lemon,Orange,Lime}


Method 9 – Using Fill Justify Command to Join Rows in Excel

 

Steps:

  • Select the range (B5:C9).

Fill Justify Command to Join Rows in Excel

  • Go to Home > Editing > Fill > Justify.

Fill Justify Command to Join Rows in Excel

  • All the text from the selected rows will be joined.


Method 10 – Using Excel Power Query Tool to Add Rows

 

Steps:

  • Select anywhere on the dataset.

Use Power Query to Concatenate Rows

  • Go to Data > From Table/Range option.

Use Power Query to Concatenate Rows

  • The Create Table dialog will appear, check the table range, and click OK.

Use Power Query to Concatenate Rows

  • A table will be visible in the Power Query Editor window.

Use Power Query to Concatenate Rows

  • From the Power Query Editor, go to Transform > Transpose.

Use Power Query to Concatenate Rows

  • The text will be separated into several columns. Select all the columns by pressing the Shift + keys.

Use Power Query to Concatenate Rows

  • Right-click on the selection and click on Merge Columns.

Use Power Query to Concatenate Rows

  • The Merge Columns dialog will appear. Choose ‘Space’ as the Separator, type the New column name, and click OK.

Use Power Query to Concatenate Rows

  • The text will be concatenated in a single cell.
  • Go to Home > Close & Load > Close & Load to close the Power Query Editor.

  • The result is now concatenated in the spreadsheet.


Method 11 – Concatenating Rows in Excel Using VBA Macro

 

Steps:

  • Select the range (B5:B9).

Concatenate Rows in Excel Using VBA in Excel

  • Right-click on the sheet name and click on the View Code to bring the VBA window. Yow can also use Alt + F11 too keys to bring the VBA window.

Concatenate Rows in Excel Using VBA in Excel

  • Enter the below code in the Module and run by pressing the F5 key. Specify in the Range where you want to see the concatenated text. I have put C5 as I want to see my result in Cell C5.
 Sub ConcatenateText()

 Dim text As Range
 Dim i As String
 For Each text In Selection
 i = i & text & " "
 Next text
 Range("C5").Value = Trim(I)

 End Sub

Concatenate Rows in Excel Using VBA in Excel

 


Things to Remember

➨ You can use both the CONCATENATE function and Ampersand (&) operator to join rows in excel. However, the CONCATENATE function can only join up to 255 strings.

➨ You cannot pass a range through the CONCATENATE function. Each of the cells must be referenced separately as: =CONCATENATE(B5,” “,B6,” “,B7,” “,B8,” “,B9).


Download Practice Workbook

You can download the practice workbook that we have used to prepare this article.

 


<< Go Back to Range | Concatenate | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Hosne Ara
Hosne Ara

Hosne Ara is a materials and metallurgical engineer who loves exploring Excel and VBA programming. To her, programming is like a time-saving superhero for dealing with data, files, and the internet. She's skilled in Rhino3D, Maxsurf C++, MS Office, AutoCAD, and Excel & VBA, going beyond the basics. With a B. Sc. in Materials and Metallurgical Engineering from Bangladesh University of Engineering and Technology, she's shifted gears and now works as a content developer. In this role, she... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo