Help needed with merged cells

F

Frank Rizzo

Hello,

I am looping through cells in the range and I am trying to figure out
whether the cell is a merged cell. If it is a merged cell, how many
columns and rows the merged area includes?

Thanks?
 
M

Monika Weber

Hi Frank,
I am looping through cells in the range and I am trying to figure out
whether the cell is a merged cell. If it is a merged cell, how many
columns and rows the merged area includes?

With the following code you can check which cells are
included in a merged range:

Sub test()
Dim c As Range, x As String
For Each c In Range("A1:E10")
If c.MergeCells Then
x = x & c.Address(False, False) & ", "
End If
Next c
MsgBox x
End Sub

Maybe it helps.
 
E

E Oveson

Here's what you would have to test if it is merged and how many rows/columns
(assuming rng is your current "cell"/range):

If rng.MergeCells Then
MsgBox "rows=" & rng.MergeArea.Rows.Count & " cols=" &
rng.MergeArea.Columns.Count
End If

-Erik
 
M

Monika Weber

Hi Frank,
I am looping through cells in the range and I am trying to figure out
whether the cell is a merged cell. If it is a merged cell, how many
columns and rows the merged area includes?

With the following code you can check which cells are
included in a merged range:

Sub test()
Dim c As Range, x As String
For Each c In Range("A1:E10")
If c.MergeCells Then
x = x & c.Address(False, False) & ", "
End If
Next c
MsgBox x
End Sub

Maybe it helps.
 

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

Top