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: Shortcut to Merge Cells.

Shortcut to Merge Cells

by Allen Wyatt
(last updated December 2, 2017)

5

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

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 (12458) 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: 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

Getting the Proper Type of Ellipses

Type three periods in a row, and the AutoCorrect feature in Word kicks in to exchange that sequence for a special ...

Discover More

Automatically Protecting After Input

Do you want user-entered data to be immediately protected so that it cannot be changed? This can be done relatively ...

Discover More

Hyperlinks from Headings to the TOC

A table of contents is a great way to help organize lengthy documents. In a default TOC, you can use each entry as a ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Rounded Corners on Cells

As you are formatting a worksheet, Excel allows you to easily add borders to cells. Adding rounded corners to cells is a ...

Discover More

Converting From Numbers to Text

If you have a range of numeric values in your worksheet, you may want to change them from numbers to text values. Here's ...

Discover More

Changing to a Non-US Date Format

Do you want to specify your months and days differently when displaying dates in your worksheets? This tip looks at how ...

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 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 nine more than 0?

2017-12-04 11:00:11

Peter Atherton

Dean Cardno

I liked your tip, but it can be shorter - this one toggles the the alignment.

Sub CentreToggle()
'Dean Cardno; xlTips
With Selection
If .HorizontalAlignment = xlCenterAcrossSelection Then
.HorizontalAlignment = xlLeft
Else: .HorizontalAlignment = xlCenterAcrossSelection
End If
End With
End Sub


2017-12-04 10:18:41

Bryan Marks

Hi, Bill,

Try this Excel Tip from Allen to see if that helps.

https://excelribbon.tips.net/T013440_Alphabetizing_Worksheet_Tabs.html

Bryan


2017-12-03 15:19:06

Bill Toney

I have a number of spreadsheets in a workbook, each being labeled year-month (Example: 2017-01, 2015-12, etc.). They were not created in sequence. Is there a way to auto sort the spreadsheets without having to manually move them?


2017-12-02 15:14:29

Dean Cardno

Sometimes merging cells is necessary, but in general it causes more problems that it solves, since it screws up subsequent paste operations. You can get the same visual result by formatting as 'centre across selection' - which is usually the reason for the merged cells in the first place. I have included the following macro in my personal macro add-in file to un-merge merged cells and apply the desired formatting:
Sub CentreAcross()


With Selection
.HorizontalAlignment = xlCenterAcrossSelection
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub

I attached it to an icon in the QAT, and use it frequently.


2017-12-02 11:08:58

Ronmio

I've never been a fan of merging cells because it can make manipulating the spreadsheet difficult. But I often want to center across a selection because it is pretty innocuous. Typically, I use this when I want a super heading to center across subordinate headings. Unfortunately, Microsoft doesn't provide a quick way to do this. So I created a macro and added it to my Quick Access Toolbar. It lets me easily center across a selection or, if it is already centered, it un-centers it. The VBA code I created is ...

Sub CenterAcrossSelection() ' Centers and un-centers across a selection
With Selection
If .HorizontalAlignment = xlCenterAcrossSelection Then ' Checks to see if it is already centered
.HorizontalAlignment = xlGeneral ' If so, un-center it using the General alignment
Else ' If it's not already centered, then
.HorizontalAlignment = xlCenterAcrossSelection ' Center across the selection
.VerticalAlignment = xlCenter ' Also center it vertically
End If
End With
End Sub


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.