protecting multiple sheets

R

Roger on Excel

I would like to protect / deprotect multiple sheets with a single password in
a single action

At present i have to protect each sheet individually, each with the same
password which is tedious, especially as i have to do each sheet each time i
protect or deprotect it.

My 10 sheets are named : St1, St2, St3.........up to St10

Ideally i would like a form to pop up when i push a button which allows me
to either protect or deprotect these 10 sheets with my password in a single
action.

Can anyone help?

Regards,

Roger
 
G

Gord Dibben

Protect all sheets...............

Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).Protect Password:="justme"
Next N
Application.ScreenUpdating = True
End Sub

Unprotect all sheets....................

Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).Unprotect Password:="justme"
Next N
Application.ScreenUpdating = True
End Sub

Protect selected sheets..........................

Sub Protect_Selected_Sheets()
Application.ScreenUpdating = False
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.Protect Password:="justme"
Next ws
Application.ScreenUpdating = True
End Sub

Unprotect selected sheets................

Sub UnProtect_Selected_Sheets()
Application.ScreenUpdating = False
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.UnProtect Password:="justme"
Next ws
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP
 
R

Roger on Excel

Thanks Gord,

Your kind help, together with posts from others has given me the code I need
to make this work nicely.

Best regards,

Roger
 

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