Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining the size of a merged area

Right, before we get off about merged cells, I hate them too, but I've to deal with them anyway. I cannot change anything about that now or in the future. As much as I would like to ;)

Say I have some merged cells, I need to determine the amount of cells it spans. Say A1:A4 are merged, then I need to have the number of merged cells, 4, returned. Is there any way to accomplish this?

like image 772
Oxymoron Avatar asked Nov 04 '09 11:11

Oxymoron


2 Answers

ActiveCell.MergeArea.Count
like image 129
Dick Kusleika Avatar answered Oct 06 '22 00:10

Dick Kusleika


You can use

Dim r As range
Dim i As Integer
    Set r = range("A1")
    i = r.CurrentRegion.Count

This will give A1:A4 as 4, A1:B4 as 8.

like image 42
Adriaan Stander Avatar answered Oct 06 '22 02:10

Adriaan Stander