ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sheet protection/unprotection (https://www.excelbanter.com/excel-programming/388810-sheet-protection-unprotection.html)

Mike D.

Sheet protection/unprotection
 
Is there a way to protect all the sheets in a workbook without specifying
each sheet separately. Currently, I select each sheet and then do
ActiveSheet.Unprotect.

Thanks,
Mike.

Mike D.

Sheet protection/unprotection
 
I found an answer:

For Each sht In ActiveWorkbook.Sheets

ActiveSheet.Protect Password:="password", DrawingObjects:=True,
Contents:=True, Scenarios:=True

Next

The same goes for unprotect.

Thanks,
Mike.



"Mike D." wrote:

Is there a way to protect all the sheets in a workbook without specifying
each sheet separately. Currently, I select each sheet and then do
ActiveSheet.Unprotect.

Thanks,
Mike.


Dave Peterson

Sheet protection/unprotection
 
Since you're working with the active sheet:

For Each sht In ActiveWorkbook.Sheets
sht.select
ActiveSheet.Protect Password:="password", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
Next sht

or without activating

For Each sht In ActiveWorkbook.Sheets
sht.Protect Password:="password", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
Next sht



Mike D. wrote:

I found an answer:

For Each sht In ActiveWorkbook.Sheets

ActiveSheet.Protect Password:="password", DrawingObjects:=True,
Contents:=True, Scenarios:=True

Next

The same goes for unprotect.

Thanks,
Mike.

"Mike D." wrote:

Is there a way to protect all the sheets in a workbook without specifying
each sheet separately. Currently, I select each sheet and then do
ActiveSheet.Unprotect.

Thanks,
Mike.


--

Dave Peterson


All times are GMT +1. The time now is 07:56 AM.

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