Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. 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: Shortcut to Merge Cells.

Shortcut to Merge Cells

by Allen Wyatt
(last updated October 22, 2015)

9

Excel allows you to merge cells together in two ways: using the Merge and Center tool on the ribbon or toolbar, or by using the controls in the Alignment tab of the Format Cells dialog box. If you merge cells quite a bit, you might long for a shortcut that will merge whatever cells you've selected.

Unfortunately, Excel doesn't include such a shortcut. You can, however, create one using a macro. The following is a simple macro to merge whatever cells you've selected:

Sub MergeCells1()
    Selection.Merge
End Sub

After you create the macro, you can assign it to a keyboard shortcut and you are set to go. If you instead want a macro that is a shortcut for the Merge and Center tool, then you can use the following:

Sub MergeCells2()
    With Selection
        .HorizontalAlignment = xlCenter
        .Merge
    End With
End Sub

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12458) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Shortcut to Merge Cells.

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

Searching for Character Formatting

Need to look for a piece of text possessing a particular formatting attribute? Here's the skinny on how this is accomplished.

Discover More

Making Your Formulas Check for Errors

Want to use a formula to check if there is an error in your formula? (Sounds confusing, but it's not that bad.) You'll love ...

Discover More

ISO Week Numbers in Excel

Work in an industry that uses ISO standards when it comes to working with dates? You'll love the formula in this tip which ...

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)

Partially Blocking Social Security Numbers

Need to protect a series of Social Security Numbers in a worksheet? The techniques provided in this tip might be a good ...

Discover More

Using Strikethrough Formatting

Need a line through the middle of your text? Use strikethrough formatting, which is easy to apply using the Format Cells ...

Discover More

Indenting Cell Contents

Excel allows you to apply several types of alignments to cells. One type of alignment allows you to indent cell contents from ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 6 - 3?

2015-10-22 07:16:48

Les Hawkins

what are the steps to create this macro and assign it a keyboard shortcut?


2015-10-22 07:15:27

Mercy Huber

David, if you click on the arrow next to the Merge & Center button you can choose Merge Across and it should do what you are looking for.


2015-08-11 18:23:42

David

Hello,

Loving this site!
I've searched for a tip on how to merge from one column to the cell next to it. I'm trying to avoid having to do the following:
1. Making a column super wide so information can all be seen
2. Going row by row to merge 790 book titles; and book descriptions.

I hope this makes sense. I'd love to be able to highlight one column and merge the cells (B1, B2, B3 - B790) to (C1, C2, C3, - C790) and NOT make one huge cell.

Also, there are typically (multiple) headers above the titles so the ask above won't work. Same scenario except in stead of columns, I'd like to highlight (B10, B11 - B790) and then merge that with the corresponding C cells (C10, C11 - C790) but the merge be row by row... not one big cell from B10 - C790.


2015-02-04 04:23:21

Rich

You, my friend, are my new hero!


2013-02-06 08:48:13

Brandon Moxley

I have modified the macro slightly to work better for me, and others may find it helpful as well.

The modification allows the cells to be unmerged, as well as merged, whereas the above macros will only merge.

Sub MergeCells()
' If the selection is already merged, unmerge it
If Selection.MergeCells Then
Selection.MergeCells = False
' Else, merge the selection(s), and center vertically and horizontally
Else
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Merge
End With
End If
End Sub


2013-02-05 07:30:01

John Summers

Thanks, Glenn. It doesn't help with my particular requirement but I've already found a use for it elsewhere!


2013-02-04 09:00:30

Glenn Case

Actually, I often to the exact opposite. Merged cells are a real pain, as they prevent you from doing many normal operations on any range they intersect (or are even parallel with), such as inserting extra columns. To address this, I have a macro which selects the entire worksheet, and then runs Selection.Unmerge top remove this impediment.

A much better solution to Merge is to use "center across selection", available under "Format Cells/Alignment."


2013-02-03 16:12:39

John Summers

I use the shorter macro via an icon on the QAT. One of the most common uses to which it is put is adjusting Report and Page Headers exported (in an annoying manner)from Crystal Reports. The investment of time involved in creating has been repaid many times over.


2013-02-02 09:02:56

Brian Hershman

Two facts to note:
(1) The merge will only work if the selected cells are consecutive AND in a straight line(i.e. row or column);
(2) it merges the [appearance of the] cells, NOT their values: the only value shown is that of the top/left-most cell


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.