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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

grizz

Active Member
Joined
Jul 28, 2009
Messages
400
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
 

alinpion

Board Regular
Joined
Jul 12, 2011
Messages
79
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
 

Watch MrExcel Video

Forum statistics

Threads
1,129,685
Messages
5,637,809
Members
416,983
Latest member
LessThanAverageUser

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
Top