Merged Cells: Any way to backtrack?

  • Thread starter Thread starter (PeteCresswell)
  • Start date Start date
P

(PeteCresswell)

If somebody sends me a worksheet that contains merged cells, Is there any way
for me to programmatically determine what the original component cells were?
 
Pete,

You could try something like the following:

Sub AAA()
Dim MergeCell As Range
Dim OrigCells As Range
Set MergeCell = Range("A3")
With MergeCell.MergeArea
Set OrigCells = .Resize(.Rows.Count, .Columns.Count)
End With
Debug.Print OrigCells.Address
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email on the web site)
 
Chip,

Why not just

Sub AAA()
Debug.print Range("A3").MergeArea.Address
End Sub

Just curious.
 
Why not just
Sub AAA()
Debug.print Range("A3").MergeArea.Address
End Sub

Absolutely no reason whatsoever. That is definitely a better option.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top