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

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

Conditional Formats that Distinguish Blanks and Zeroes

Conditional formatting is a great tool. You may need to use this tool to tell the difference between cells that are empty or ...

Discover More

Developing Reciprocal Conversion Formulas

When converting between measurement systems, you might want to use two cells for each type of measurement. Make a change in ...

Discover More

Customizing File Explorer's Display

File Explorer is a powerful utility to use for navigating among your files and folders. And it can be customized a great deal ...

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)

Changing Number Display Settings for Single Workbooks

How Excel displays numbers is extremely flexible, but it can also be very confusing. This tip looks at how number display is ...

Discover More

Drawing Borders

Adding borders around cells is a common formatting task. You can make the task more intuitive by actually drawing the borders ...

Discover More

Using Fractional Number Formats

If you want information to display on the screen using fractions instead of decimals, you're in luck. Excel provides ...

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 two more than 4?

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.