Hello everyone, I have a file that I use for quoting. For each product I have the following sheets/tabs....Cost, Financial Model, NPV, Sensitivity, and Amort. When I have multiple products I am quoting at the same time I end up having one file with a very long list of sheets.
I want to be able to have one sheet/tab called "Show Product 1" and when I click that it shows all 5 sheets/tabs mentioned above and changes the name to "Hide Product 1". When I click on "Hide Product 1" I want to hide all 5 of those sheets and change the name back to "Show Product 1"
I found this VBA online but I am having difficulty with it - exact part is show below in red.
Private Sub Worksheet_Activate()
Dim sheet As Worksheet
Application.ScreenUpdating = False
If ShowHide.Name = "Show Product 1" Then
'Make all sheets visible
For Each sheet In ThisWorkbook.Sheets
sheet.Visible = xlSheetVisible
Next sheet
'Change the sheet name to the "Collapse" name you want
ShowHide.Name = "Hide Product 1"
'Pick a sheet to display after the once hidden sheets are expanded
Sheet4.Activate
Else
'Hide all sheets except the ones you want to keep visible
For Each sheet In ThisWorkbook.Sheets
If (sheet.Name <> Results.Name And sheet.Name <> Run.Name And sheet.Name <> ShowHide.Name) Then
sheet.Visible = xlSheetVeryHidden
End If
Next sheet
'Change the sheet name to the "Expand" name you want
ShowHide.Name = "Show Product 1"
'Pick a sheet to display after the sheets to be hidden are collapsed
Run.Activate
End If
Application.ScreenUpdating = True
End Sub
PLEASE HELP!
I want to be able to have one sheet/tab called "Show Product 1" and when I click that it shows all 5 sheets/tabs mentioned above and changes the name to "Hide Product 1". When I click on "Hide Product 1" I want to hide all 5 of those sheets and change the name back to "Show Product 1"
I found this VBA online but I am having difficulty with it - exact part is show below in red.
Private Sub Worksheet_Activate()
Dim sheet As Worksheet
Application.ScreenUpdating = False
If ShowHide.Name = "Show Product 1" Then
'Make all sheets visible
For Each sheet In ThisWorkbook.Sheets
sheet.Visible = xlSheetVisible
Next sheet
'Change the sheet name to the "Collapse" name you want
ShowHide.Name = "Hide Product 1"
'Pick a sheet to display after the once hidden sheets are expanded
Sheet4.Activate
Else
'Hide all sheets except the ones you want to keep visible
For Each sheet In ThisWorkbook.Sheets
If (sheet.Name <> Results.Name And sheet.Name <> Run.Name And sheet.Name <> ShowHide.Name) Then
sheet.Visible = xlSheetVeryHidden
End If
Next sheet
'Change the sheet name to the "Expand" name you want
ShowHide.Name = "Show Product 1"
'Pick a sheet to display after the sheets to be hidden are collapsed
Run.Activate
End If
Application.ScreenUpdating = True
End Sub
PLEASE HELP!