Found this function on mrexcel:
https://www.mrexcel.com/board/thread...evels.1061148/
It lets you switch between your outline levels:
Option Explicit
Public Function LowestRowGroupLevelDisplayed( _
Optional ByVal Worksheet As Worksheet _
) As Long
Dim Row As Range
Dim LowestLevel As Long
If Worksheet Is Nothing Then Set Worksheet = ActiveSheet
For Each Row In Worksheet.UsedRange.Rows.EntireRow
If Not Row.Hidden Then
If Row.OutlineLevel > LowestLevel Then LowestLevel = Row.OutlineLevel
End If
Next Row
LowestRowGroupLevelDisplayed = LowestLevel
End Function
Sub testGRp()
If (LowestRowGroupLevelDisplayed = 1) Then
ActiveSheet.Outline.ShowLevels RowLevels:=3
Else
ActiveSheet.Outline.ShowLevels RowLevels:=1
End If
End Sub
The code expands/collapses all your groups at once, though.
Might there be a way to add an "input line" to set certain ranges of rows and columns?
To say e.g. "rows 4-6" or "columns K-L"?
(I haven't used any functions yet, I'm a bit overwhelmed.)
Right now, I hide/unhide specific rows and columns with a "Flip Switch":
' Flip alpha
Sub Flip_alpha()
Dim Title As String
Dim i As Integer
Title = Range("A1")
i = 0
Do While Sheet1.Range("A1").Offset(0, i).Value <> Title
i = i + 1
Loop
Sheet1.Range("A1").Range("A4:A8").Select
' Set Rows
Selection.EntireRow.Hidden = Not Selection.EntireRow.Hidden
' ' Set Columns
' Selection.EntireColumn.Hidden = Not Selection.EntireColumn.Hidden
End Sub
This works just fine, but takes quite some time to build.
Set range, add rectangle (transparent) as button, create click, assign "call" to rectangle.
For every group. And in the end, it's not even the real deal, e.g. it leaves certain cells "selected" (screenshot).
And for now, this only allows me to switch between "Level closed" and "Level max expanded".
I'd have to have extra sets of macros for every level, right?
1) Set/Select range 2) Add rectangle 3) Create click 4) Assign to rectangle
I've attached the workbook, all codes included.
The merged cells with the double arrows are all working flip buttons, expanding and collapsing.
So now I wonder, if that function can be tweaked?
Might that result in less code?
Thank you for any help!
Bookmarks