I agree that it would be bullet proof however it relies on the user to hide the sheets before saving. There is no way to guarantee that they do this! Too much risk!
One may not want the password to be found directly in the sheet code. Here comes an improved version of Smitty:
Private Sub Worksheet_Activate()
Dim pswrd As String
Dim pword As String
Call password_request(pswrd)
pword = InputBox("Please Enter a Password", "Unhide Sheets")
If pword <> pswrd Then ActiveSheet.Visible = False
End Sub
Sub password_request(pswrd As String)
Dim iFileNo As Integer
iFileNo = FreeFile
'open the file for reading
Open "C:\UPC\excel_password.txt" For Input As #iFileNo
' Read password
Input #iFileNo, pswrd
'close the file
Close #iFileNo
End Sub
Welcome to the Board!
This is one way:
Private Sub Worksheet_Activate()
****pword = InputBox("Please Enter a Password", "Unhide Sheets")
****If pword <> "pword" Then ActiveSheet.Visible = False
End Sub
The code goes in the module specific to the sheet that is hidden. When the user selects Format-->Sheet-->Unhide, the sheet will be unhidden, but they will be asxked for a pasxsword. If they get it wrong, the sheet will be rehidden.
Hope that helps,
Smitty
I want to hide a sheet and I can do that. However, what I want to do it that when the user wants to view the sheet I just hid, he has to unhide and then enter a password. Right now tthere is no password.