Hello,
I am trying to combine the following three macros. My goal is upon close of the workbook, to unhide all hidden sheets, clear all filters on all pages, hide all sheets except one called Landing Page.
Macro 1
Sub vba_unhide_all_sheet()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Sheets
If ws.Visible = False Then
ws.Visible = True
End If
Next ws
End Sub
Macro 2
Private Sub Workbook_beforeclose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
With ws
If (Activesheet.AutoFilterMode And Activesheet.FilterMode) Or Activesheet.FilterMode Then
Activesheet.ShowAllData
End If
End With
Next ws
End Sub
Macro 3
Sub HideWorksheets()
Dim ws As Worksheet
For Each wst In ThisWorkbook.Worksheets
If ws.Name <> ThisWorkbook.ActiveSheet.Name Then
ws.Visible = xlSheetHidden
End If
Next ws
End Sub
I have tried various combinations of the above three macros to no avail. All would need to be in the Private Sub Workbook_beforeclose macro.
Any and all help is greatly appreciated!!
I am trying to combine the following three macros. My goal is upon close of the workbook, to unhide all hidden sheets, clear all filters on all pages, hide all sheets except one called Landing Page.
Macro 1
Sub vba_unhide_all_sheet()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Sheets
If ws.Visible = False Then
ws.Visible = True
End If
Next ws
End Sub
Macro 2
Private Sub Workbook_beforeclose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
With ws
If (Activesheet.AutoFilterMode And Activesheet.FilterMode) Or Activesheet.FilterMode Then
Activesheet.ShowAllData
End If
End With
Next ws
End Sub
Macro 3
Sub HideWorksheets()
Dim ws As Worksheet
For Each wst In ThisWorkbook.Worksheets
If ws.Name <> ThisWorkbook.ActiveSheet.Name Then
ws.Visible = xlSheetHidden
End If
Next ws
End Sub
I have tried various combinations of the above three macros to no avail. All would need to be in the Private Sub Workbook_beforeclose macro.
Any and all help is greatly appreciated!!