View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Roger on Excel Roger on Excel is offline
external usenet poster
 
Posts: 249
Default protecting multiple sheets

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

"Gord Dibben" wrote:

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

On Sun, 3 Aug 2008 17:35:02 -0700, Roger on Excel
wrote:

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