How to super hide and unhide excel sheets using VBA code ?

If you want to super hide the worksheets in excel, excel has an very hidden property.

When the sheets are very hidden, if you right click and try to unhide such sheets, the unhide view gets disabled. As there will be no worksheets to view.

Use the below steps to test the very hidden property of the excel sheets.

Open new worksheet

Press Alt + F11 to go to VBA editor window

Insert new module from the project explorer

Copy and paste the below code to try out:

Sub SuperHide()

‘This property will super hide the sheets
Sheet1.Visible = xlVeryHidden

End Sub

We will not be able to unhide this sheet1 from excel window. For that we would need to write a vba code for unhide.

Sub UnHide()

‘This property will unhide the sheets. True over here reprents the xlSheetVisible property
Sheet1.Visible = True

End Sub

This will unhide the sheet and you will be able to see the same in excel window.

You can add multiple sheets in a similar way and use both the hide and unhide codes for different uses. If you don’t want to super hide the sheet, you can also use the below code to just hide the sheet.

Sub Hide()

‘This property will simply hide the sheets. False over here represents the xlSheetHidden property
Sheet1.Visible = False

End Sub

This will hide the sheets and in this case, you will be able to unhide the sheet from the Excel Window.

You can also use the below keyboard shortcuts to hide or unhide sheets for faster use.
Hide – Alt, O, H, H

Unhide – Alt, O, H, U

Just in case if you don’t want any one to go in VBA code and unhide the super hidden sheets. You can protect the VBA module with password of your choice.

Check the post How to protect vba module in excel ? for the same.

Please leave a reply if you like the article or if you need any help on excel

%d bloggers like this: