How to lock each tab with a different password?

alinpion

Board Regular
Joined
Jul 12, 2011
Messages
79
Hello!

I have a excel document with 5 tabs (sheets) and, because different people work with a different tab (sheet), I want to lock each tab (sheet). I want the tab to be visible on the tab bar but when you click on it you will not be able to see the content of that tab (sheet) until you provide the right password (each tab with a different pasword).
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
right click on your tab and click view code then paste this code in and change your password
Code:
Private Sub Worksheet_Activate()
Dim pwd As String:  pwd = "mypassword"
Cells(Rows.Count, Columns.Count).Activate
    If Application.InputBox("What is the password to view this sheet?", "Access Password", "******") <> pwd Then
        Sheets("Sheet1").Activate
        MsgBox "Wrong password"
    Else
        Range("A1").Activate
    End If
 
End Sub

for each sheet / tab use different password
 
Upvote 0
The code works but now I have another problem:

If you put the code (with password) in all sheets save and then when you open it, the document will enter in the last sheet that you write and save without asking you for a password.

The solution in my opinion will be:

When I open the file I want a window to appear and ask me what sheet I want to use and after I chose the sheet another window appears and ask's me to enter the password for the chosen sheet
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,762
Members
449,048
Latest member
excelknuckles

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