ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protecting worksheets (https://www.excelbanter.com/excel-discussion-misc-queries/134143-protecting-worksheets.html)

Bryan Potter

Protecting worksheets
 
I have a workbook containing some 250 worksheets.

Is there some way to protect all worksheets in a workbook instead of having
to protect each one individually?

Thanks,

Bryan

Mike

Protecting worksheets
 
This should do it.

Sub protectall()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Select
ActiveSheet.Protect Password:="yourpassword"
Next ws
End Sub

Mike

"Bryan Potter" wrote:

I have a workbook containing some 250 worksheets.

Is there some way to protect all worksheets in a workbook instead of having
to protect each one individually?

Thanks,

Bryan


Bryan Potter

Protecting worksheets
 
How would the script be changed to unprotect all the worksheets?

Thanks for your help,

Bryan

"Mike" wrote:

This should do it.

Sub protectall()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Select
ActiveSheet.Protect Password:="yourpassword"
Next ws
End Sub

Mike

"Bryan Potter" wrote:

I have a workbook containing some 250 worksheets.

Is there some way to protect all worksheets in a workbook instead of having
to protect each one individually?

Thanks,

Bryan


Mike

Protecting worksheets
 
By having a second macro very similar to the one below and cunningly adding

UN in front of protect.

Mike

"Bryan Potter" wrote:

How would the script be changed to unprotect all the worksheets?

Thanks for your help,

Bryan

"Mike" wrote:

This should do it.

Sub protectall()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Select
ActiveSheet.Protect Password:="yourpassword"
Next ws
End Sub

Mike

"Bryan Potter" wrote:

I have a workbook containing some 250 worksheets.

Is there some way to protect all worksheets in a workbook instead of having
to protect each one individually?

Thanks,

Bryan



All times are GMT +1. The time now is 09:49 PM.

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