protect & unprotect sheets

  • Thread starter Thread starter Khalil Handal
  • Start date Start date
K

Khalil Handal

Is there a way to protect and unprotect *multiple* sheets at once. All the
sheets have the same password (say 1234).
 
Khalil

You could use code like below, but cannot do it through the UI

Sub ProtectAll()
Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
wks.Protect Password:="1234"
Next wks
End Sub

Sub UnProtectAll()
Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect Password:="1234"
Next wks
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
web: www.nickhodge.co.uk
blog (non-tech): www.nickhodge.co.uk/blog/
 
If you have sheets within a workbook that are all password protected with
"secret", then this small macro will un-protect all at once:

Sub AtRisk()
MyPass = "secret"
For Each sh In Sheets
sh.Unprotect (MyPass)
Next
End Sub
 
Thank you both. It worked fine

Gary''s Student said:
If you have sheets within a workbook that are all password protected with
"secret", then this small macro will un-protect all at once:

Sub AtRisk()
MyPass = "secret"
For Each sh In Sheets
sh.Unprotect (MyPass)
Next
End Sub
 
Back
Top