How to set password for multiple worksheet and to hide ?

  • Thread starter Thread starter Mah
  • Start date Start date
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
 
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
 
Back
Top