This will be easy peasy for people in here but i need a hand with my wee bit of code which groups or ungroups rows. Basically i want the VBA to establish if the sheet grouping is 1 then make it 2 but then stop. If the same button is pressed again the macro will see that grouping is 2 so then make it 1 and then stop. But when i press my button it's obviously running through all the code at the same time and therefore when it finishes in reality i'm back to how it started if that makes sense?
Code:
Sub group()
'
' group Macro
Worksheets("P&L").Select
If ActiveSheet.Outline.ShowLevels(RowLevels:=1) Then
ActiveSheet.Outline.ShowLevels RowLevels:=2
ElseIf ActiveSheet.Outline.ShowLevels(RowLevels:=2) Then
ActiveSheet.Outline.ShowLevels RowLevels:=1
End If
End Sub
Last edited by a moderator: