How to set a sheet to very hidden using VBA?

In VBA (Visual Basic for Applications), you can set a worksheet to “Very Hidden” by modifying the `Visible` property of the sheet object. When a sheet is set to “Very Hidden,” it cannot be unhidden by a regular user through the Excel interface—it can only be made visible again via VBA or through the VBA editor. Here’s how you can do it:

Sub SetSheetVeryHidden()
    ThisWorkbook.Sheets("SheetName").Visible = xlSheetVeryHidden
End Sub
  • Open your Excel workbook.
  • Press `Alt + F11` to open the VBA editor.
  • In the Project Explorer window, find the workbook and the sheet you want to hide.
  • Double-click the relevant worksheet or module to open the code window.
  • Enter the following VBA code to set the sheet to Very Hidden:

Replace `”SheetName”` with the actual name of the sheet you want to hide.

  • Run the macro by pressing `F5` or through the menu.

If you need to unhide the sheet later, you can set the `Visible` property back to `xlSheetVisible`:

Sub UnhideSheet()
    ThisWorkbook.Sheets("SheetName").Visible = xlSheetVisible
End Sub

To provide a complete solution, if you do not have the “Developer” tab enabled, you can do so by:

  • Go to File > Options.
  • Select “Customize Ribbon.”
  • Check the “Developer” option in the right-hand box under Main Tabs.

After this, you can access the VBA editor more conveniently.

These steps should help you manage the visibility of your sheets with VBA.

Unlock Your Potential

Excel

Basic - Advanced

Access

Access Basic - Advanced

Power BI

Power BI Basic - Advanced

Help us grow the project