retrieving rowlevels

  • Thread starter Thread starter Stefi
  • Start date Start date
S

Stefi

Hi All,

How can I tetrieve rowlevels last set?
E.g.

After executing
ActiveSheet.Outline.ShowLevels RowLevels:=3
I want to retrieve 3.

Thanks,
Stefi
 
I think you're going to have to loop through the cells to find it.

I saved this from a longgggggg time ago. Maybe it'll give you an idea.

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

It just cycles through the visible cells in column A and checks to see if that's
the biggest one found.
 
Thanks, Dave, I hoped Excel provides a simple answer to this question. The
only key I found in Help was OutlineLevel property and I hardly beleived that
one has to scan all cells to retrieve this information.

Anyway, I'm going to use your code, you have spared some time for me.

Regards,
Stefi


„Dave Peterson†ezt írta:
 
I had that same feeling!
Thanks, Dave, I hoped Excel provides a simple answer to this question. The
only key I found in Help was OutlineLevel property and I hardly beleived that
one has to scan all cells to retrieve this information.

Anyway, I'm going to use your code, you have spared some time for me.

Regards,
Stefi

„Dave Peterson†ezt írta:
 
Hi Dave,

I'm satisfied not being alone with my opinion. Anyway, the code works
perfectly, I created a function from it.

Regards,
Stefi

„Dave Peterson†ezt írta:
 
Remember that there is no safety in numbers <vbg>.
Hi Dave,

I'm satisfied not being alone with my opinion. Anyway, the code works
perfectly, I created a function from it.

Regards,
Stefi

„Dave Peterson†ezt írta:
 

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