can I find merged cells?

D

David McDonald

I'm trying to sort and get the message "merged cells must be the same size".
How can I 'find' the merged cells?
 
P

Paul B

David, here is a macro by Dave Peterson that will do it

Sub Found_Merged_Cells()

'macro looks for merged cells

'By Dave Peterson

Dim myCell As Range

Dim resp As Long



For Each myCell In ActiveSheet.UsedRange.Cells

If myCell.MergeCells Then

If myCell.Address = myCell.MergeArea(1).Address Then

resp = MsgBox(prompt:="found: " _

& myCell.MergeArea.Address & vbLf & _

"Continue looking", Buttons:=vbYesNo)

If resp = vbNo Then

Exit Sub

End If

End If

End If

Next myCell



End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 2003
** remove news from my email address to reply by email **
 
I

icestationzbra

select the region that you are trying to sort (that seem to have th
merged cells) and then run this macro. it will pop up messages with th
cell addresses.

Option Explicit

Sub MergedCells()

Dim rng As Range

For Each rng In Selection

If rng.MergeCells = True Then

MsgBox "Merged Cells " & rng.Address

End If

Next rng

End Sub

hope this was the requirement
 
Top