Excel.Tips.Net ExcelTips (Menu Interface)

Identifying Merged Cells

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Identifying Merged Cells.

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:

  1. Press Ctrl+F. Excel displays the Find tab of the Find and Replace dialog box.
  2. If necessary, click the Options button to make sure the Find and Replace dialog box is expanded to show all options. (See Figure 1.)
  3. Figure 1. The Find tab of the Find and Replace dialog box.

  4. Make sure the Find What box is empty.
  5. With the insertion point in the Find What box, click the Format button. Excel displays the Find Format dialog box.
  6. Make sure the Alignment tab is displayed. (See Figure 2.)
  7. Figure 2. The Alignment tab of the Find Format dialog box.

  8. Make sure the Merge Cells check box is selected (there should be a check in the check box).
  9. Click OK to close the Find Format dialog box.
  10. Click Find All.

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
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
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
    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 (3905) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Identifying Merged Cells.

Related Tips:

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!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

bitflip    24 Mar 2016, 12:48
It has been suggested on other forums that using the "UsedRange" method is unpredictable and should be avoided.

I have to admit to not remembering why exactly but it was something about Excel not updating something after cells had been deleted or cleared, and somehow the UsedRange method would point to those deleted cells even though they didn't exist any more.

I found this information on stackoverflow and a few other forums as well as a tutorial site that explained why it shouldn't be used. Here is one such stackoverflow page that has a very short explanation:

I'm at work so I don't have time to find more resources to backup my claim, but it may be wise to look into this more for yourself as well as how to work around using the UsedRange method if possible.
nyandi    08 Mar 2016, 03:07
How to get the merged cell Address or range

Bulent    19 Oct 2015, 15:16
Sub Macro1()
With Application.FindFormat
        .WrapText = False
        .ShrinkToFit = False
        .MergeCells = True
End With
MsgBox ActiveSheet.Cells.Find(What:="", SearchFormat:=True, SearchOrder:=xlByRows, LookIn:=xlFormulas, MatchCase:=False, LookAt:=xlPart, SearchDirection:=xlNext).Address
End Sub
Ivor Shaer    07 Feb 2015, 01:12
Is it possible to create a list of merged ranges in a worksheet? The code would add a new worksheet and list the merged ranges in column A, one under the other, as follows:

Ely    19 Nov 2014, 13:44
Thanks a LOT for this tip! VERY USEFUL! :)
Peter R. Cross    23 Mar 2013, 01:34
I am not yet a VBA programmer, but want a variation that finds any merged cells in the sheet and UN-merges them. (Some data has single-row records combined with two-row records, those containing vertically-merged cell-pairs. All data is in the upper (original) cells of those vertical pairs, so once UN-merged, I can clean up easily. If someone wants to send me this annotated as a "lesson" in VBA, I will probably catch on quick.
Peg Molter    18 May 2012, 13:47
Very helpful! I just discovered today that searching for text can return a false negative if a)your search is initiated from a cell adjacent to a merged group, and b (and the weirdest part), the search box specifies "by rows" if rows were merged, or "by columns" if columns were merged. Makes me vow NEVER to merge either again. Too much data integrity compromised by doing so.
PJP    17 May 2012, 09:15
'*** How about this modification ***'

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 & Replace(c.Address, "$", "") & vbCr
        End If
    If sMsg = "" Then
        sMsg = "No merged worksheet cells."
    End If

    MsgBox sMsg
End Sub

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2017 Sharon Parq Associates, Inc.