ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help needed with merged cells (https://www.excelbanter.com/excel-programming/315725-help-needed-merged-cells.html)

Frank Rizzo

Help needed with merged cells
 
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?


Monika Weber

Help needed with merged cells
 
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.

--
Greetings,
Monika Weber [Microsoft MVP für Excel]
http://www.jumper.ch (Office Help Desk)



E Oveson[_3_]

Help needed with merged cells
 
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

"Frank Rizzo" wrote in message
...
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?




Monika Weber

Help needed with merged cells
 
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.

--
Greetings,
Monika Weber [Microsoft MVP für Excel]
http://www.jumper.ch (Office Help Desk)




All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com