Hide / Unhide Worksheets using Excel VBA (Excel 2007)
Here is the simple code to Hide and unhide Worksheet:
Sub Hide_Unhide_Worksheets()
Dim oWS As Worksheet
On Error GoTo Err_Filter
oWS = Worksheets(1)
' hide the sheet - user cannot unhide
oWS.Visible = xlSheetVeryHidden
' To make the sheet visible
oWS.Visible = xlSheetVisible
Finally:
If Not oWS Is Nothing Then oWS = Nothing
Err_Filter:
If Err <> 0 Then
MsgBox(Err.Description)
Err.Clear()
GoTo Finally
End If
End Sub
Here are the values for XLSheetVisibility. Hides the Worksheet so that the only way for you to make it visible again is by setting this property to True (the user cannot make the Worksheet visible).
Name | Description | |
xlSheetHidden | Hides the worksheet which the user can unhide via menu. | |
xlSheetVeryHidden | Hides the object so that the only way for you to make it visible again is by setting this property to True (the user cannot make the object visible). | |
xlSheetVisible | Displays the sheet. |
No comments:
Post a Comment