Option Explicit
'---------------------------------------------------------------------------------------
' Module : Module1
' DateTime : 04/03/2007 08:48
' Author : Roy Cox (royUK)
' Website : www.excel-it.com for more examples
' Purpose : remove all merged cells from workbook
' Disclaimer; This code is offered as is with no guarantees. You may use it in your
' projects but please leave this header intact.
'---------------------------------------------------------------------------------------
Public Sub ClearMerged()
Dim oWs As Excel.Worksheet
Dim rCL As Excel.Range
Dim uRng As Excel.Range
Dim MyAddr As String
Dim r As Long
Dim c As Long
Dim LastRow As Long
Dim LastColumn As Long
On Error Resume Next
Application.ScreenUpdating = False
For Each oWs In ActiveWorkbook.Worksheets
oWs.Select
Set uRng = oWs.UsedRange
LastRow = uRng.Rows(uRng.Rows.Count).Row
LastColumn = uRng.Columns(uRng.Columns.Count).Column
' Find the merged cells
For r = 1 To LastRow
For c = 1 To LastColumn
Cells(r, c).Select
MyAddr = Selection.Address
If Len(WorksheetFunction.Substitute(MyAddr, ":", "")) <> Len(MyAddr) Then
With Range(MyAddr)
.Select
.MergeCells = False
End With
End If
Next c
Next r
Next oWs
Set uRng = Nothing
On Error GoTo 0
Application.ScreenUpdating = True
End Sub