Hello,
I have the below code to toggle my grouped columns in excel to expand and contract (the code doesn't remove the grouping), how do I amend this code so that this only applies to specific columns e.g. A:E and leaves all my other grouped columns
Thanks
Public Function LowestRowGroupLevelDisplayed( _
Optional ByVal Worksheet As Worksheet _
) As Long
Dim column As Range
Dim LowestLevel As Long
If Worksheet Is Nothing Then Set Worksheet = ActiveSheet
For Each column In Worksheet.UsedRange.Rows.EntireColumn
If Not column.Hidden Then
If column.OutlineLevel > LowestLevel Then LowestLevel = column.OutlineLevel
End If
Next column
LowestRowGroupLevelDisplayed = LowestLevel
End Function
Sub testGRp()
If (LowestRowGroupLevelDisplayed = 1) Then
ActiveSheet.Outline.ShowLevels columnLevels:=2
Else
ActiveSheet.Outline.ShowLevels columnLevels:=1
End If
End Sub
I have the below code to toggle my grouped columns in excel to expand and contract (the code doesn't remove the grouping), how do I amend this code so that this only applies to specific columns e.g. A:E and leaves all my other grouped columns
Thanks
Public Function LowestRowGroupLevelDisplayed( _
Optional ByVal Worksheet As Worksheet _
) As Long
Dim column As Range
Dim LowestLevel As Long
If Worksheet Is Nothing Then Set Worksheet = ActiveSheet
For Each column In Worksheet.UsedRange.Rows.EntireColumn
If Not column.Hidden Then
If column.OutlineLevel > LowestLevel Then LowestLevel = column.OutlineLevel
End If
Next column
LowestRowGroupLevelDisplayed = LowestLevel
End Function
Sub testGRp()
If (LowestRowGroupLevelDisplayed = 1) Then
ActiveSheet.Outline.ShowLevels columnLevels:=2
Else
ActiveSheet.Outline.ShowLevels columnLevels:=1
End If
End Sub
Last edited: