How can I find out the Maximum Outline Rowlevel?

  • Thread starter Thread starter Wassim
  • Start date Start date
W

Wassim

Hi!

My problem is the following:

I can display certain Rowlevels by using this command:

ActiveSheet.Outline.ShowLevels RowLevels:=2

But I want to find out how many rowlevels there are.
Does anybody have any clue about this?

Thank you in advance!

Wassi
 
You're looking for the highest level or the highest level visible?

This just checks visible cells:

Option Explicit
Sub testme99()
Dim myRange As Range
Dim myCell As Range
Dim maxLevel As Long

With ActiveSheet
Set myRange = Intersect(.Columns(1), .UsedRange) _
.SpecialCells(xlCellTypeVisible)

maxLevel = 0
For Each myCell In myRange.Cells
If myCell.EntireRow.OutlineLevel > maxLevel Then
maxLevel = myCell.EntireRow.OutlineLevel
End If
Next myCell

End With
MsgBox "Largest visible level: " & maxLevel

End Sub

If you want all the cells, then this:
Set myRange = Intersect(.Columns(1), .UsedRange) _
.SpecialCells(xlCellTypeVisible)
becomes
Set myRange = Intersect(.Columns(1), .UsedRange)
 

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

Back
Top