Dr. Demento
Well-known Member
- Joined
- Nov 2, 2010
- Messages
- 618
- Office Version
- 2019
- 2016
- Platform
- Windows
How could I adapt the code below to only give the range of a block the merged cells once and then move on to the next merged block?
For example: if Range("A1:A4") and Range ("C5:C10") are merged, I'd like the output to be
"A1:A4 is merged"
"C5:C10 is merged"
NOT
"A1 is merged"
"A2 is merged"
. . . (8 more times) . . .
"C10 is merged"
Source: Allen Wyatt
Somehow, I'm wondering if cycling thru each .MergeArea or .MergeCells is a solution, but I don't know how to implement it.
Also, I'm not interested in UnMerging the block, just identifying the location.
Any thoughts? Thanks, y'all.
For example: if Range("A1:A4") and Range ("C5:C10") are merged, I'd like the output to be
"A1:A4 is merged"
"C5:C10 is merged"
NOT
"A1 is merged"
"A2 is merged"
. . . (8 more times) . . .
"C10 is merged"
Code:
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
Somehow, I'm wondering if cycling thru each .MergeArea or .MergeCells is a solution, but I don't know how to implement it.
Also, I'm not interested in UnMerging the block, just identifying the location.
Any thoughts? Thanks, y'all.