简体   繁体   中英

Count all levels with no outlines as children

I am trying to find a solution to count the number of rows which are at the last outline level. In the image as you can see this is the result I desire. I want to detect a row in the Range where the outline level only has children and no other outline level below. 在此处输入图像描述

Could anybody offer some pointers in how to find this outline level please?

The outline level of a range (row or column) can be checked using OutlineLevel . As far as I see, you want to compare the outline level with the one of the next row: If the outline level of the next row is larger, it is a child, else the row has no childs. Check the next function:

Function hasChildren(r As Range) As Boolean
    hasChildren = r.EntireRow.OutlineLevel < r.Offset(1, 0).EntireRow.OutlineLevel
End Function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM