ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protect / Unprotect Sheets (https://www.excelbanter.com/excel-programming/306504-protect-unprotect-sheets.html)

Rob F[_2_]

Protect / Unprotect Sheets
 
Hi

Can anyone provide two simple macros to protect all sheets
in a workbook, and the opposite - i.e. unprotect all
sheets?

Ideally, I'd then like to move on to designing a form that
lists all the worksheets that I can toggle protection or
or off from. But first things first!

Thanks

Rob F

papou[_7_]

Protect / Unprotect Sheets
 
Hello Rob
Sub Protect()
For Each f In Sheets
f.Protect '("pwd") optional if password
Next f
End Sub

Sub Unprotect()
For Each f In Sheets
f.Unprotect '("pwd") optional if password
Next f
End Sub

HTH
Cordially
Pascal

"Rob F" a écrit dans le message de
...
Hi

Can anyone provide two simple macros to protect all sheets
in a workbook, and the opposite - i.e. unprotect all
sheets?

Ideally, I'd then like to move on to designing a form that
lists all the worksheets that I can toggle protection or
or off from. But first things first!

Thanks

Rob F




Rob F[_2_]

Protect / Unprotect Sheets
 
Pascal

Great, does just what I want.

Thanks

Rob

Don Guillett[_4_]

Protect / Unprotect Sheets
 
Sub toggleprotect()
With ActiveSheet
If .ProtectContents = True Then
.Unprotect
Else
.Protect
End If
End With
End Sub


--
Don Guillett
SalesAid Software

"Rob F" wrote in message
...
Hi

Can anyone provide two simple macros to protect all sheets
in a workbook, and the opposite - i.e. unprotect all
sheets?

Ideally, I'd then like to move on to designing a form that
lists all the worksheets that I can toggle protection or
or off from. But first things first!

Thanks

Rob F





All times are GMT +1. The time now is 05:36 AM.

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