In this post, you’ll will learn about some tips and tricks on how to hide and unhide worksheet using Excel VBA.
Hide Sheet in VBA
To hide a Sheet in Excel VBA, Set the Visible property to FALSE.
Code:
Worksheets("Sheet1").visible = Falseor
Worksheets("Sheet1").visible = xlSheetHiddenUnhide Sheet
To unhide a Sheet in VBA,
Code:
Worksheets("Sheet1").Visible = Trueor
Worksheets("Sheet1").Visible = xlSheetVisibleVery Hidden Sheets
The xlSheetVeryHidden property,
Code:
Worksheets("Sheet1").Visible = xlSheetVeryHiddenUnhide Very Hidden Sheets
To unhide very hidden sheets.
Code:
Worksheets("Sheet1").Visible = Trueor
Worksheets("Sheet1").Visible = xlSheetVisibleHide and Unhide Sheets in the VBA Editor
You can also toggle the Worksheet Visible property within the VBA Editor:
Hide and Unhide Sheets in Protected Workbook
To hide or unhide sheets in a protected workbook, you need to unprotect it first.
Code:
 ActiveWorkbook.Unprotect
If it is password protected, then
Code:
ThisWorkbook.Unprotect "password"
Now you can unhide all the hidden sheets.
Unhide All Sheets
Using for each loop, you can unhide all sheets in a workbook.
Code:
Sub Unhide_Sheets_VBAEditor()
    Dim ws As Worksheet
   ActiveWorkbook.Unprotect
    For Each ws In Worksheets
        ws.Visible = xlSheetVisible
    Next
End Sub 
															

 
								 
								