how to password protect a single tab in a workbook in excel 2010

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?
Answer
Answer
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

 

If this response answers your question then please mark as answer.

Mike H

225 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated May 13, 2024 Views 80,840 Applies to: