How To Hide A Sheet In Excel Vba

To hide a sheet in Excel using VBA, you can use the “.Visible” property of the worksheet. By setting this property to “xlSheetHidden” or “xlSheetVeryHidden”, you can hide the sheet from the user’s view. Here’s how it can be done:

    
Sub HideSheetExample()
    ThisWorkbook.Sheets("Sheet1").Visible = xlSheetHidden
End Sub

Sub VeryHideSheetExample()
    ThisWorkbook.Sheets("Sheet1").Visible = xlSheetVeryHidden
End Sub
    
  

The first example hides the sheet, but the user can still unhide the sheet through the Excel interface. The second example uses “xlSheetVeryHidden” to hide the sheet in such a way that it cannot be unhidden via the Excel interface. However, keep in mind that this can be undone through VBA code.

To unhide a hidden sheet, you can set the “.Visible” property to “xlSheetVisible”. Here’s an example:

    
Sub UnhideSheetExample()
    ThisWorkbook.Sheets("Sheet1").Visible = xlSheetVisible
End Sub
    
  

Same cateogry post

Leave a comment