@Zane Usernames, passwords and permitted sheets to viewable are not in the code but are all contained on a worksheet called Users.This worksheet is normally hidden but is visible when a user with Admin rights opens the workbook.
Replace this with the following code: "u2pass" Then b Error = True Case Else b Error = True End Select End If If b Error Then Msg Box "Invalid User Name or Password" Else 'Set document property b Set It = False For Each p In Active Workbook. When the user clicks on the OK button, the procedure checks to make sure that the combination of the user name and password is correct. If it is, then the authorized sheet name is stored in a document variable and the appropriate sheet is displayed and unprotected.
If you want to change the acceptable user names, sheet names, and passwords, you can do so by making the desired changes in the Select Case structure near the top of this macro code. Save End If End Sub Private Sub Workbook_Open() User Form1.
The code I have provided should be used as a starting point for people to develop their own variants to meet their particular requirements.3.
This is something that I will add in the future but, to date, I haven't had the time to do this.
I like how you have integrated both methods (user sheet & password masked) as per your updated file on 31st of January 2017 in your reply to Daniel.
1) However, whenever I try to save the workbook before I close it, excel freezes for more than 5 minutes, and then succeeds to save the workbook.
This need is a bit trickier to accommodate, but it can be done.
The basic approach would be as follows: Steps 1, 2, and 5 are easy enough to do, and have been covered in other issues of Excel Tips.
What if you want to limit access to the worksheets entirely, however?