Macro to protect/unprotect with password
Public const m_cPassword = "MyPassword"
Public Sub ProtectAll()
Dim wks As Worksheet
Application.ScreenUpdating = False
For Each wks In Worksheets
On Error Resume Next
Select Case Trim(wks.Name)
Case "Start" 'Don't protect the start sheet
Case "Main" 'Don't protect the main sheet
Case Else
wks.Protect m_cPassword
End Select
Next wks
Application.ScreenUpdating = True
End Sub
Public Sub UnProtectAll()
Dim wks As Worksheet
Application.ScreenUpdating = False
For Each wks In Worksheets
On Error Resume Next
wks.Unprotect m_cPassword
Next wks
Application.ScreenUpdating = True
End Sub
--
HTH...
Jim Thomlinson
"Cam" wrote:
Hi.
I have an Excel Protected template file (2000') that I need to unprotect
several sheets (20) in order to perform work, then protected back with the
same password to distribute to users.
Currently I am doing this manual which can be time consuming. How can I
create a macro to protect/unprotect sheet with a click of a button?
Thanks for any help and suggestion.
|