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

Searching for Paragraph Marks and Line Breaks

Word allows you to search not for special characters that normally do not print such as paragraph marks and line breaks.

Discover More

Entering Regular Text in the Equation Editor

The Equation Editor is a great tool for designing and displaying all sorts of equations in a document. It is not very ...

Discover More

Avoiding a Section Break Booby Trap

Section breaks got your document formatting all messed up? It could be because of the way you added the section breaks in ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Printing a Multi-Line Footer

Add a footer to your document and you may want to make it span more than a single line. This can be easy to do, provided ...

Discover More

Hiding Individual Cells

Hiding information in one or more cells can be a challenge. This tip presents several different techniques that can help ...

Discover More

Select One Cell and Make Another Cell Bold

Excel provides a number of different ways you can apply formatting to a cell based upon various dynamic conditions. One ...

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 six more than 7?

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.