phenixwars
New Member
- Joined
- Feb 20, 2015
- Messages
- 15
Hello I have created some buttons that have macros assigned to them to expand/collapse grouped rows on click.
There are two levels of grouped rows. One level, which has its own Expand All button, will expand/collapse all groups. The other level is just an Expand button which will expand/collapse the smaller groups within the large group. The macro works fine on the first sheet, making all the buttons disappear when I collapse all (expect for the Expand All button), but then on the other sheets when I apply the same macro the buttons for the smaller groups of rows all bundle and show underneath the Expand All button. This is a problem only because if these buttons were to be clicked they cause the file to expand random rows and throws the whole sheet into a mess where you can only collapse and expand some groups and not others.
I have used the original macro from sheet 1 and just renamed it for each different sheet. I suspect that this is my problem. I'm wondering if there is a proper macro that will do the same thing but will recognize the active sheet and apply itself to it without interfering with the other sheets.
Here is a link to download a sample of my workbook: https://onedrive.live.com/redir?resid=6D21E9845F393FE7!22850&authkey=!AOHJsFR5USpKJV8&ithint=file%2cxlsm Don't open this with Excel Online because for some reason it doesn't show the buttons.
Here are the macros I'm using:
Expand All Button Macro:
Public Trigger As Boolean
Sub LevelShow()
If Trigger = False Then
Sheets(1).Outline.ShowLevels RowLevels:=2
Trigger = True
Else
Sheets(1).Outline.ShowLevels RowLevels:=1
Trigger = False
End If
End Sub
******
Expand Button macro:
Sub ExpandorCloseGroup()
Dim CB As Shape
Set CB = ActiveSheet.Shapes(Application.Caller)
TlcRow = CB.TopLeftCell.Row
If Rows(TlcRow + 0).ShowDetail = True Then
Rows(TlcRow + 0).ShowDetail = False
Else
If Rows(TlcRow + 0).ShowDetail = False Then
Rows(TlcRow + 0).ShowDetail = True
End If
End If
End Sub
******
Thank you in advance for all your help!
There are two levels of grouped rows. One level, which has its own Expand All button, will expand/collapse all groups. The other level is just an Expand button which will expand/collapse the smaller groups within the large group. The macro works fine on the first sheet, making all the buttons disappear when I collapse all (expect for the Expand All button), but then on the other sheets when I apply the same macro the buttons for the smaller groups of rows all bundle and show underneath the Expand All button. This is a problem only because if these buttons were to be clicked they cause the file to expand random rows and throws the whole sheet into a mess where you can only collapse and expand some groups and not others.
I have used the original macro from sheet 1 and just renamed it for each different sheet. I suspect that this is my problem. I'm wondering if there is a proper macro that will do the same thing but will recognize the active sheet and apply itself to it without interfering with the other sheets.
Here is a link to download a sample of my workbook: https://onedrive.live.com/redir?resid=6D21E9845F393FE7!22850&authkey=!AOHJsFR5USpKJV8&ithint=file%2cxlsm Don't open this with Excel Online because for some reason it doesn't show the buttons.
Here are the macros I'm using:
Expand All Button Macro:
Public Trigger As Boolean
Sub LevelShow()
If Trigger = False Then
Sheets(1).Outline.ShowLevels RowLevels:=2
Trigger = True
Else
Sheets(1).Outline.ShowLevels RowLevels:=1
Trigger = False
End If
End Sub
******
Expand Button macro:
Sub ExpandorCloseGroup()
Dim CB As Shape
Set CB = ActiveSheet.Shapes(Application.Caller)
TlcRow = CB.TopLeftCell.Row
If Rows(TlcRow + 0).ShowDetail = True Then
Rows(TlcRow + 0).ShowDetail = False
Else
If Rows(TlcRow + 0).ShowDetail = False Then
Rows(TlcRow + 0).ShowDetail = True
End If
End If
End Sub
******
Thank you in advance for all your help!