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: Identifying Merged Cells.
by Allen Wyatt
(last updated April 1, 2021)
Alan asked if there is a way to quickly and easily identify which cells are merged in a workbook created by someone else. There are, in reality, several different ways you can go about identifying these cells.
One method for identifying the cells is to use Excel's searching capabilities. Follow these steps:
Figure 1. The Find tab of the Find and Replace dialog box.
Figure 2. The Alignment tab of the Find Format dialog box.
Excel searches for any merged cells and if they are located, the cells are displayed in the bottom of the Find and Replace dialog box. You can then select one of the found ranges and the corresponding range is selected in the worksheet.
If you prefer, you can a macro to find the various merged cells in the worksheet. The following macro shows perhaps the simplest method of doing this:
Sub FindMerged1() Dim c As Range For Each c In ActiveSheet.UsedRange If c.MergeCells Then MsgBox c.Address & " is merged" End If Next End Sub
This particular macro steps through all the cells in the worksheet (well, at least those that are in the UsedRange) and, if the cell is part of a merged cell, a message box is displayed. Note that the pertinent property being checked is the MergeCells property. This is set to True if the cell is merged with another cell.
Of course, a macro such as this can take quite a long time to run if the worksheet has lots of cells and even longer if a good number of those cells are merged. Your macro would run faster if it didn't stop at each merged cell and display a dialog box. The following version takes a different approach, filling each merged cell with a yellow color:
Sub FindMerged2() Dim c As Range For Each c In ActiveSheet.UsedRange If c.MergeCells Then c.Interior.ColorIndex = 36 End If Next End Sub
A variation on this approach could be to create a user-defined function that simply returns True or False if the cell is merged:
Function FindMerged3(rCell As Range) FindMerged3 = rCell.MergeCells End Function
With this simple function you could then use conditional formatting to somehow highlight cells if they are merged. (If the function returns True, then conditional formatting applies whatever formatting you specify to the cell.)
Finally, if you want a list of cells that are merged in the worksheet, you can simply have your macro put together the list instead of coloring the cells:
Sub FindMerged4() Dim c As Range Dim sMsg As String sMsg = "" For Each c In ActiveSheet.UsedRange If c.MergeCells Then If sMsg = "" Then sMsg = "Merged worksheet cells:" & vbCr End If sMsg = sMsg & c.Address & vbCr End If Next If sMsg = "" Then sMsg = "No merged worksheet cells." End If MsgBox sMsg End Sub
This variation displays a single message box at the end of the macro, indicating the addresses of any merged cells located in the worksheet.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12385) 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: Identifying Merged Cells.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
If you need to determine the font applied to a particular cell, you’ll need to use a macro. This tip presents several ...Discover More
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
Want to repeat cell contents over and over again within a single cell? Excel provides two ways you can duplicate the content.Discover More