Counting number of grouped/outlined rows

D

Dirk Flakowski

Hello,

I use the outline/group-functionality very extensively so that I
always use 3-5 levels of them. Now in my program it is necessary for
me to know how many rows are part of an outline.
So I just closed the group, counted the number of visible rows, opened
the group and again counted the number of rows -> the difference then
is the number of rows inside the group/outline.
But now I recognized that it no more works if inside of that group
again groups exist which are closed. Then all the rows of this
group/outline are just counted as one row, but not the number of all
the rows inside of it.

So is there are any possibility to get the number of rows inside one
group/outline easily?

I know, I could open all groups/outlines inside the one I have to
count recursively, but due to my huge worksheets this will take quite
long so that this is nearly impossible for me.

Does anyone have any idea or just a hint what I could do?

Thanks in advance.
Dirk
 
B

Bill Manville

Dirk said:
So is there are any possibility to get the number of rows inside one
group/outline easily?

Function NumberOfRowsInOutlineLevel(Level As Integer) As Long
Dim R As Range
Dim L As Long
For Each R In ActiveSheet.UsedRange.EntireRow.Rows
If R.OutlineLevel = Level Then L = L+1
Next
NumberOfRowsInOutlineLevel = L
End Function



Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup
 

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