K Khalil Handal Jun 24, 2007 #1 Is there a way to protect and unprotect *multiple* sheets at once. All the sheets have the same password (say 1234).
Is there a way to protect and unprotect *multiple* sheets at once. All the sheets have the same password (say 1234).
N Nick Hodge Jun 24, 2007 #2 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/
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/
G Guest Jun 24, 2007 #3 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
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
K Khalil Handal Jun 24, 2007 #4 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 Click to expand...
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 Click to expand...
G Gord Dibben Jun 24, 2007 #5 See response at the other thread you tagged onto. Gord Dibben MS Excel MVP