Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. 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 November 11, 2022)
This tip applies to Excel 2007, 2010, 2013, and 2016


6

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.

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, and 2016. 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

Measurement of Choice Isn't Persistent

Normally, Word allows you to specify what measurement units you want used for the program; just choose Tools | Options | ...

Discover More

Making Squares

Cells in a worksheet defined by the intersection of rows and columns. If you adjust row height and column width just ...

Discover More

Hiding Fonts

Windows makes it easy to manage the fonts installed on your system. One of the lesser-known options is one that allows ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Entering the Current Time

Need to enter the current time into a cell? It's easy to do using this keyboard shortcut. The shortcut is a handy one to ...

Discover More

Disabling Dragging and Dropping

Excel allows you to easily paste information into a worksheet, including through simply dragging and dropping the ...

Discover More

Using AutoComplete with Disjointed Lists

AutoComplete can help you to more quickly enter information in a worksheet. How it works, behind the scenes, can affect ...

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 8 - 2?

2023-01-30 10:12:42

J. Woolley

The Tip mentions Home > Editing > Fill > Justify. That feature is rather obscure, but My Excel Toolbox includes the FillJustifyText macro to make it less so.

First the macro displays information in a MsgBox (see Figure 1 below)
Then the macro uses Application.InputBox to define a Range (see Figure 2 below)
Next the macro saves content of the Range plus 100 rows directly below it to prepare for Undo (because running a macro always empties the Undo stack).
Finally the macro applies the Range.Justify method described here:
https://learn.microsoft.com/en-us/office/vba/api/excel.range.justify

See https://sites.google.com/view/MyExcelToolbox
And for more on this subject, see the following:
https://excelchamps.com/excel-basics/fill-justify
https://www.myonlinetraininghub.com/who-needs-word-when-excel-has-got-fill-justify-text
https://www.theexceladdict.com/tips/151115-Instead-Of-Using-Wrap-Text,-Justify-Text-On-Multiple-Rows.html

Figure 1. 

Figure 2. 


2022-11-11 09:43:18

Alan Cannon

2 comments:
(1) don't forget to turn on "Wrap Text" for the destination either before or after the combining, or
(2) replace the blank character " " with an ASCII line feed


2017-06-30 03:00:23

Stephen

Ah yes, sorry. I tried to do it for columns rather than rows. That doesn't work!


2017-06-29 03:00:52

Shreepad SM Gandhi

Thanks Allen
Wasn't aware that Fill-Justify could also be used this way. Tried it. Nice.
Stephen, 
Even I use Excel 2010. It worked well for me. Am wondering why you couldn't succeed. Suggest to follow just the way explained in this tip. Hope it works.
Andrew, 
I guess Excel 2010 doesn't has this Excel function TEXTJOIN. However I do have Excel 2013 on my another machine. Shall try that for sure. Thanks for sharing.


2017-06-24 08:52:40

Stephen

"Another approach works very well...." This simply does not work for me using Excel 2010.


2017-06-24 05:42:33

Andrew

There is a new function in Excel, TEXTJOIN, available in the latest version of Excel.

Allen's formula above could be replaced with
=TEXTJOIN(" ",TRUE,C6:C9)

The first argument is the delimiter you wish to use, and the second relates to how empty cells are treated.

More detail is at https://support.office.com/en-us/article/TEXTJOIN-function-357b449a-ec91-49d0-80c3-0e8fc845691c.


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.