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

Changing Page Margins

Part of determining page layout is to specify the size of the margins that surround the text on a page. Word allows you ...

Discover More

Inserting Footnotes Using Custom Footnote Marks

Automatic footnotes are easy to insert in Word documents. The default settings are usually fine for most projects. ...

Discover More

Skipping Numbering

Got a numbered list, but you want to add other types of non-numbered paragraphs in the middle of the list? It's easy to ...

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)

Setting Orientation of Cell Values

Need the contents of a cell to be shown in a direction different than normal? Excel makes it easy to have your content ...

Discover More

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

Retaining Formatting After a Paste Multiply

You can use the Paste Special feature in Excel to multiple the values in a range of cells. If you don't want Excel to ...

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 four more than 2?

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.