Specific sheet access by user/password

sampson32

Active Member
Joined
Jul 16, 2003
Messages
312
Office Version
  1. 2021
Platform
  1. Windows
I have a workbook with 10 sheets.

Each sheet needs to be protected by a different password.

When a user logs in I would like them to be directed to a specific sheet and all other sheets hidden

I found some references to this on the forum but they had no code that I could try.

How could this be accomplished?

Thank you,

Sam
 
for clarification

Where "Sheet1" refers to the actual sheet name. Just change it to reflect your sheet name.

If my Sheet1 is "emp1" i should change Sheets("Sheet1") to
Sheets("emp1")?

If so, I tried that and still it is a no go. i get the same error message
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
for clarification

Where "Sheet1" refers to the actual sheet name. Just change it to reflect your sheet name.

If my Sheet1 is "emp1" i should change Sheets("Sheet1") to
Sheets("emp1")?

If so, I tried that and still it is a no go. i get the same error message
Yes, but note that any leading or trailing spaces in the sheet name will throw off the code too. It has to be the exact name.

Smitty
 
Upvote 0
dude you rock... i finally got it to work. i will add for the rest of the tabs.

now to figure out how to get all of the worksheets to open for the manager of the group. I will try to figure out the code listed above. if needed could i pick your brain again???

again, thank you for all your help.
 
Upvote 0
What I do for admin type tasks is test for user name.

Code:
Private Sub Workbook_Open()
    Dim AdminUser As String
        AdminUser = Environ("username")
        
        If AdminUser = "DefinedUserName" Then Exit Sub
        
        '   Password Code here
            
End Sub
And bail from the code if it's not you or your manager.

Smitty
 
Upvote 0
I never knew there was a "how can I show all sheets" question added to this thread or I surely would've answered. :eek:

That can be done as simply as adding this to the previously posted code, right above the End Select line...
Code:
Case "Boss's Name"
        If pWord = "Boss's Password" Then
            For ws = 1 To WSCount
              Sheets(ws).Visible = True
            Next ws
        End If
This way it'll work no matter who's username is being used, as long as the user knows the boss's password. - ( :devilish: )

Hope it helps.

[Hey Smitty. How everything? You guys get all moved in?]
 
Upvote 0
Thanks HalfAce. the boss's code workes like a charm.

Pennysaver - hats off to you too.

I really appreciate all the help from you guys :LOL:
 
Upvote 0

Forum statistics

Threads
1,221,838
Messages
6,162,286
Members
451,759
Latest member
damav78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top