View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Unprotecting Several Sheets At Once

Sub unprotectall()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).UnProtect Password:="password"
Next N
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP


On Thu, 11 Dec 2008 09:52:00 -0800, Zee
wrote:

I have some code entered in to protect all the sheets upon close however I
would like to be able to unprotect them all by only entering the password
once as it is the same for all the sheets.

Thanks

Private Sub Workbook_BeforeClose(Cancel As Boolean)

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


End Sub