A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I would like to be able to password protect a single tab within a workbook. I need the information on this one tab to not be able to be seen unless you have the necessary password to get into it. Is this possible?
Hi,
There are several ways to this but you need to bear in mind that they will only deter the honest. Anyone with the will to do so can bypass any protection you put in place very quickly indeed so in short if you let anyone open this workbook and they are intent on seeing this sheet then they can. However, here's the method I use.
ALT+F11 to open VB editor. Double click 'ThisWorkbook' and paste the code below in on the right. Change the name at the start of the code to the correct one and close VB editor. The password is currently set to a case sensitive MyPass
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim MySheets As String, Response As String
MySheet = "Sheet1"
If ActiveSheet.Name = MySheet Then
ActiveSheet.Visible = False
Response = InputBox("Enter password to view sheet")
If Response = "MyPass" Then
Sheets(MySheet).Visible = True
Application.EnableEvents = False
Sheets(MySheet).Select
Application.EnableEvents = True
End If
End If
Sheets(MySheet).Visible = True
End Sub