ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protection Macro (https://www.excelbanter.com/excel-programming/405569-protection-macro.html)

santaviga

Protection Macro
 
Hello.

I'm looking for a macro to run to protect all worksheets in a workbook, I
have about 50 worksheets and its a lot of work going through the protection
menu for every worksheet, Can someone give me a macro to run so when run it
protects all worksheets in the workbook and also one to run to unprotect all
worksheets in a workbook.

many Thanks

Gord Dibben

Protection Macro
 

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

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


Gord Dibben MS Excel MVP

On Mon, 4 Feb 2008 14:02:00 -0800, santaviga
wrote:

Hello.

I'm looking for a macro to run to protect all worksheets in a workbook, I
have about 50 worksheets and its a lot of work going through the protection
menu for every worksheet, Can someone give me a macro to run so when run it
protects all worksheets in the workbook and also one to run to unprotect all
worksheets in a workbook.

many Thanks



santaviga

Protection Macro
 
Many thanks

"Gord Dibben" wrote:


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

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


Gord Dibben MS Excel MVP

On Mon, 4 Feb 2008 14:02:00 -0800, santaviga
wrote:

Hello.

I'm looking for a macro to run to protect all worksheets in a workbook, I
have about 50 worksheets and its a lot of work going through the protection
menu for every worksheet, Can someone give me a macro to run so when run it
protects all worksheets in the workbook and also one to run to unprotect all
worksheets in a workbook.

many Thanks





All times are GMT +1. The time now is 08:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com