Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Unprotecting Several Sheets At Once

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Unprotecting Several Sheets At Once

From Excel's help menu:
ActiveWorkbook.Unprotect

Modify your macro accordingly...

Regards,
Ryan---

--
RyGuy


"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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Unprotecting Several Sheets At Once

You can use code very similar to the code you use to protect the sheets:

Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim N As Single, pwd
pwd = InputBox("Enter password")
If Len(pwd) = 0 Then Exit Sub
For N = 1 To Sheets.Count
Sheets(N).Unprotect Password:=pwd
Next N
Application.ScreenUpdating = True
End Sub

Hope this helps,

Hutch

"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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unprotecting Sheets Zee[_2_] New Users to Excel 6 November 26th 08 03:58 PM
Unprotecting Sheets with VBA and IRM Howard Excel Programming 1 August 1st 06 10:03 AM
Unprotecting Sheets Darren Excel Programming 1 May 18th 06 08:22 PM
Unprotecting Sheets with VBA and IRM Philip Excel Programming 0 December 4th 05 04:18 AM
unprotecting sheets one Excel Programming 2 April 17th 04 07:06 PM


All times are GMT +1. The time now is 11:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"