Robert_Conklin
Board Regular
- Joined
- Jun 19, 2017
- Messages
- 173
- Office Version
- 365
- Platform
- Windows
- MacOS
I have the following sub that unhides all sheets in a workbook. I would like to use the button I assigned to the ribbon to hide all of the sheets when I click it again.
I tried copying the code, but changing the ws.Visible setting to xlSheetHidden, but the button does nothing when the sheets are visible. Any help would be awesome!
VBA Code:
Sub Unhide_Multiple_Sheets()
Dim ws As Worksheet
'The For-Next is a loop that loops through
'each sheet in the active workbook
For Each ws In ActiveWorkbook.Worksheets
'Set the visible property of the sheet (ws)
'to visible (xlSheetVisible)
ws.Visible = xlSheetVisible
Next ws
End Sub
I tried copying the code, but changing the ws.Visible setting to xlSheetHidden, but the button does nothing when the sheets are visible. Any help would be awesome!