Forum Discussion
Sbookman
Aug 07, 2024Copper Contributor
Protecting Specific Tabs in a Workbook from Viewing
Hi, I am trying to see if there is a way to protect/block specific tabs in an Excel workbook from viewing, not just editing. And is there a way to give different permissions/vies/access to differen...
Harun24HR
Aug 07, 2024Bronze Contributor
Sbookman Excel is not really appropriate for these type of complex security. Either you can protect full workbook or you have to use some tricks but not documented security. Here one approach to protect a sheet with password to view. Lets try it. You download the attached file.
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim MySheetName As String
MySheetName = "HiddenSheet" 'The sheed which I want to hide.
If Application.ActiveSheet.Name = MySheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
response = Application.InputBox("Password", "Enter Password", "", Type:=2)
If response = "123456" Then 'Unhide Password.
Application.Sheets(MySheetName).Visible = True
Application.Sheets(MySheetName).Select
End If
End If
Application.Sheets(MySheetName).Visible = True
Application.EnableEvents = True
End Sub