ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Beta - unprotecting multiple sheets (https://www.excelbanter.com/excel-programming/276993-beta-unprotecting-multiple-sheets.html)

Rick[_15_]

Beta - unprotecting multiple sheets
 
I have a workbook with over 40 sheets i need to unprotect
and protect from time to time. Can it be done faster than
each sheet at a time?

Thanks for your help


Ken Wright

Beta - unprotecting multiple sheets
 
Couple of routines from JE McGimpsey


Public Sub ToggleProtect1()
'Courtesy of J E McGimpsey
Const PWORD As String = "ken"
Dim wkSht As Worksheet
Dim statStr As String

For Each wkSht In ActiveWorkbook.Worksheets
With wkSht
statStr = statStr & vbNewLine & "Sheet " & .Name
If .ProtectContents Then
wkSht.Unprotect Password:=PWORD
statStr = statStr & ": Unprotected"
Else
wkSht.Protect Password:=PWORD
statStr = statStr & ": Protected"
End If
End With
Next wkSht
MsgBox Mid(statStr, 2)
End Sub


Sub Toggleprotect2()
'Courtesy of J E McGimpsey
Const PWORD As String = "ken"
Dim wkSht As Worksheet

For Each sh In ActiveWorkbook.Worksheets
If sh.ProtectContents = False Then
sh.Protect PWORD
Else
sh.Unprotect PWORD
End If
Next sh
End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL2K & XLXP

----------------------------------------------------------------------------
Attitude - A little thing that makes a BIG difference
----------------------------------------------------------------------------



"Rick" wrote in message ...
I have a workbook with over 40 sheets i need to unprotect
and protect from time to time. Can it be done faster than
each sheet at a time?

Thanks for your help





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

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