Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Combining Multiple Rows in a Column.

Combining Multiple Rows in a Column

Written by Allen Wyatt (last updated July 1, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


2

Bonnie described a common problem that occurs when importing a file into Excel. The file being imported is a scanned text file, and the import goes just fine, with one small glitch: in one column where there was wrapped text in the original document, the text now occupies several rows in the worksheet. Bonnie is looking for a way to combine those rows back into a single cell in that column.

There are a couple of ways this can be done. If you don't have to do this too often, a formulaic approach may be best. Just use the ampersand (&) to concatenate the contents of the rows you want to combine:

=C6 & " " & C7 & " " & C8 & " " & C9

The result is all the text combined into a single cell. You can copy this result to the Clipboard and use Paste Special to put it into the final cell where you need it. Finally, you can delete the original multiple rows that are no longer needed.

If you are using Excel 2019 or later (including Excel in Microsoft 365), then you can use the TEXTJOIN function to do the combining:

=TEXTJOIN(" ", TRUE, C6:C9)

The first parameter for the TEXTJOIN function indicates what you want between the combined cell contents, the second parameter indicates that you want empty cells ignored, and the final parameter indicates the range you want to combine.

Another approach works very well if the cells you want to combine all contain text. Let's say you want to combine cells C6:C9. All you need to do is to widen column C so it could contain the contents of those cells on a single line. Then, select the cells. Display the Home tab of the ribbon and note that there is a tool in the Editing group called Fill. If you click the tool you see a drop-down list of options from which you should choose Justify. When you do, you end up with all the values in cell C6, separated by spaces.

If you need to concatenate cells quite often, you may benefit from a simple macro:

Sub Combine()
    Dim J As Integer

    If Selection.Cells.Count > 1 Then
        For J = 2 To Selection.Cells.Count
            Selection.Cells(1).Value = _
              Selection.Cells(1).Value & " " & _
              Selection.Cells(J).Value
            Selection.Cells(J).Clear
        Next J
    End If
End Sub

To use this macro, select the cells you want to concatenate and then run the macro. The contents of all the cells are combined into the first cell in the selection, then whatever is in the other cells is cleared. The macro doesn't delete any rows; that is left for you to do. It does, however, combine the contents quickly—even more quickly if you assign a shortcut key to the macro.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11496) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Combining Multiple Rows in a Column.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Formatting Text Files with VBA

Got a bunch of text that you've imported from a text file? Need to make it look better? You can take a stab at it with ...

Discover More

Displaying Excel's Developer Tab

The Developer tab of the ribbon is the gateway to many advanced features in Excel, including those features related to ...

Discover More

Converting a Table into Text

Word includes a powerful table editor that allows you to create and work with tables easily. At some point, however, you ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Pasting Multiple Paragraphs Into a Single Cell

Copying information from one program (such as Word) to another (such as Excel) is a common occurrence. If you want to ...

Discover More

Selecting Formulas

Want to select only the formulas in your worksheet? It's easy to do using the Go To Special dialog box.

Discover More

Weird Pasting Behavior

The Clipboard is integral to editing data in your worksheets. What happens, though, when the Clipboard doesn't allow you ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2023-07-07 07:30:50

R. Whitlock

I have a similar macro that uses chr(10) to join the strings so that they can be displayed on separate lines within the cell with text wrapped.


2023-07-01 13:53:39

J. Woolley

Re. the Tip's paragraph that begins "Another approach....":
My Excel Toolbox includes the FillJustifyText macro to redistribute text constants from the selection's first column to fit within the selected columns and rows. Therefore, as mentioned in the Tip, if the selection's first cell is wide enough to contain all of the selected text, then all of it will be moved there. And the reverse is also possible; text constants that overflow the selection's first column can be redistributed across several selected columns and rows by the FillJustifyText macro.
See https://sites.google.com/view/MyExcelToolbox


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.