How to set password for multiple worksheet and to hide ?

M

Mah

How am I to set different password for different worksheet ? This to allow
certain person to see only certain worksheet when clicking on one password
"123". I'm new Macro. Your guidance please
 
R

Robert McCurdy

Ok, you are going to write down all your passwords first?

Sub ProtectAllSheets()
Dim wks As Worksheet, Pswd As String
Pswd = "mypassword" 'change to your one
For Each wks In ActiveWorkbook.Worksheets
wks.Protect Password:=Pswd & wks.Index
Next wks
End Sub

To Unprotect:

Sub UnProtectAllSheets()
Dim wks As Worksheet, Pswd As String
Pswd = "mypassword" 'use your password
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect Password:=Pswd & wks.Index
Next wks
End Sub


Paste these 2 into a new code module (Alt + F11 and insert module)
Then to run them Alt + F8 will show them, under Options there you can create a short cut key combination.

Regards
Robert McCurdy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top