I would go about it by having a worksheet called "usernames" that is always xlSheetVeryHidden.
Worksheets("usernames") = xlSheetVeryHidden
And then in column A store the usernames and in column B store the passwords. (Username can be the name of the worksheet you are hiding.)
So have a userform popup with 2 different entries. 1 for the username and 1 for the password.
Search the hidden worksheet by looping through each value in column A. (http://www.mrexcel.com/td0058.html)
'pseudocode
For Each value in column A
If userform username = seclected value in column A
Check password.
If password is ok
Worksheets("username") = xlSheetVisible
Else
MsgBox "Wrong password."
End If
Else
MsgBox("User does not exist."
End If
Next value in column A
See what you can do with the above. It is pseudocode so it won't work but should help you get started.
Tutorial:
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Sheet1" Then ws.Visible = xlSheetVeryHidden
Next ws
ThisWorkbook.Save 'saves wb again without asking
End Sub
Option explicit means you have to define all your variables as a data type.
So "Dim someVariable As String"
means you made a variable called someVariable and it will hold data of the type "String".
The next line means for each worksheet in the workbook you will check the sheets. If the first worksheet is not the first sheet then you hide it. Repeat and check all the worksheets.
The final line saves it.
If you want to select which sheets are hidden or not hidden you need to change that code.
'Wrong way
Worksheets(ws) = xlSheetVeryHidden
'correct way
Worksheets("PUT THE NAME OF ANY SHEET HERE") = xlSheetVeryHidden
Worksheets("PUT SOME OTHER NAME HERE") = xlSheetVeryHidden
Hope this gives you a good start.
Bookmarks