Protection

G

Guest

Hi, I have a workbook with over 100 sheets in it and each sheet is protected,
at the moment I am unprotecting each sheet one at a time, is there an easyer
way to do this, unprotect or protect all the sheets at the same time, so I
can make changes to all in one go?.
Any ideas.
Thanks in advance, Barry.
 
G

Guest

These might help.........(watch out for the word-wrap)

Sub ProtectSheets()
Worksheets("sheet1").Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, password:="aaa"
Worksheets("sheet2").Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, password:="bbb"
Worksheets("sheet3").Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, password:="ccc"
End Sub

Sub UnProtectSheets()
Worksheets("sheet1").Unprotect password:="aaa"
Worksheets("sheet2").Unprotect password:="bbb"
Worksheets("sheet3").Unprotect password:="ccc"
End Sub


Vaya con Dios,
Chuck, CABGx3
 
M

meatshield

These might help.........(watch out for the word-wrap)

Sub ProtectSheets()
Worksheets("sheet1").Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, password:="aaa"
Worksheets("sheet2").Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, password:="bbb"
Worksheets("sheet3").Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, password:="ccc"
End Sub

Sub UnProtectSheets()
Worksheets("sheet1").Unprotect password:="aaa"
Worksheets("sheet2").Unprotect password:="bbb"
Worksheets("sheet3").Unprotect password:="ccc"
End Sub

Vaya con Dios,
Chuck, CABGx3

If the password is the same for every sheet in the worbook:
Sub Protect_All()
Const STR_PASSWORD As String = "password"
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In Sheets
sh.Protect STR_PASSWORD
Next sh
Application.ScreenUpdating = True
End Sub

Sub UnProtect_All()
Const STR_PASSWORD As String = "password"
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In Sheets
sh.Unprotect STR_PASSWORD
Next sh
Application.ScreenUpdating = True
End Sub
 

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