Excel includes a handy tool that you can use to merge cells and center whatever is within those merged cells. (This tool is available on the Home tab of the ribbon, in the Alignment group.) The problem with this tool is that it merges prior to centering, and you might not want any merged cells in your worksheet.
Fortunately, Excel includes the capability of centering information across a range of cells, without merging them. There is no native tool on any ribbon tab that can perform this task. You can, however, display the Alignment tab of the Format Cells dialog box and use the Horizontal drop-down list to choose Center Across Selection. Doing this frequently within a worksheet can be a pain, but you can create your own tool to center information across whatever cells you've selected:
Sub CenterAcrossColumns() With Selection .HorizontalAlignment = xlCenterAcrossSelection .MergeCells = False End With End Sub
Once you have the macro, you can assign it to a shortcut key or the Quick Access Toolbar.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12183) 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: Creating a Center Across Selection Button.
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!
How Excel displays numbers is extremely flexible, but it can also be very confusing. This tip looks at how number display ...
Discover MoreNeed to replace the formats applied to some cells with a different format? You can use Excel's Find and Replace tool to ...
Discover MoreBorders on all sides of a cell are easy to do in Excel. You can also create diagonal borders that run right through the ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2019-03-13 10:24:25
John Mann
I routinely use as macro to centre across selection on worksheets which are NOT macro eneables. I have the macro in my PEERSONAL.XLSB workbook, and added an icon on the QAT to run it. I just tried it out on a new workbook which hadn't even been saved yet..
In an earlier post in this thread David Gray suggested that an add in would be more versatile, which is a good suggestion for some people, but for me I don't have to worry about other users on my computer. As for an undo - for me this is a rare requirment, so I'm OK with messing about in the ribbon.
2019-03-10 11:28:22
Michael Krailo
@David Gray, not sure what version you are using but in 2010 and 2013, there is not button on the home tab to do this. Maybe you are confusing the "Merge across" with what we are talking about here which is "Center Across Selection". I hate merged cells especially when mixed in with the actual data. Not good. Fine on reports, but bad in any area that stores data since any macro's will have to un-merge them anyway to do anything with the sheet.
The disadvantage of using macros like this is there is no Ctrl-Z to go back. So probably need yet another macro to reverse it.
2017-10-21 08:49:22
Jim Lennington
The main drawback of this work around is that it requires the spreadsheet to be macro enabled. Most spreadsheets are not macro enabled and having to 'save as ' and rename the file is an extra step. What is is going to take to get Microsoft to add this feature to the ribbon?
2016-10-03 23:38:52
David Gray
@Willy Vanhaelen, thank you for calling attention to the mention of the built-in tool.
@John Mann, there are several ways to make this macro universal. By far the easiest, though least versatile, is to store it in PERSONAL.XLSB. The reason that I think of this as the least versatile is that it becomes part of your individual settings. Another, more versatile option, is to incorporate the macro into an add-in, which is nothing more than a macro-enabled workbook with all of its worksheets hidden. The advantage of an add-in is that it can be made available to all users on a machine, and can be distributed to other users.
2016-10-03 11:05:33
Kevin Miller
I like the Merge Across option but is there a way to have it combine all the text from all merged cells. If I select a range and choose the Merge Across it only keeps the value in the upper left cell and discards everything else. Sometimes I want to merge all the cells into a single cell with the combined content of all cells value in one long string. Thanks,
2016-10-03 09:08:15
John Mann
Does this macro have to reside on the individual workbook, or can it be made universal?
2016-10-03 08:44:51
I use this command all the time - thanks for this tip! Now to create a keyboard shortcut for it would be the next step.
2016-10-02 05:52:18
Willy Vanhaelen
@David Gray
The last sentence of the first paragraph says clearly that the button on the home tab merges prior to centering. I mostly don't want the cells to be merged so I use this macro already for years and find it very useful.
2016-10-02 00:38:22
David Gray
Using a macro to do this seems like overkill, since the default Home tab already has a button that does it for you.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2022 Sharon Parq Associates, Inc.
Comments