I'm trying to improve a macro in an EXCEL spreadsheet. The spreadsheet has multiple tabs (sheets), some of which have grouped rows in them. My "cleanup" routine needs to check to see if these grouped rows exist. Is there some code that does this (hopefully boolean)?

If it helps, I'm using the following code to group:

    Rows(begRow & ":" & endRow).Select

However I only want to ungroup these sheets if grouping exists on the page anywhere.


Thanks for your help.


Hi Ron,
Me again.
This little snip may help you out:

Sub Macro1()
' Macro1 Macro

    If Cells("2").Rows.OutlineLevel = 2 Then
    End If
 ' in this little snippet, if row nr 2 has a level of 2
 ' rows 2 to 4 get ungrouped
 ' if OutlineLevel = 1 there is no grouping applied
 ' with nested groupings, OutlineLevel might be higher than 2

End Sub