Try this also:
Code:
Sub ProtectAll()
Dim wSheet As Worksheet
Dim Pwd As String
Pwd = InputBox("Enter your password to protect all worksheets", "Password Input")
If Pwd = vbNullString Then GoTo ExitPoint
For Each wSheet In Worksheets
wSheet.Protect Password:=Pwd
Next wSheet
ExitPoint:
'Memory cleaning
Set wSheet = Nothing
Pwd = vbNullString
End Sub
Sub UnProtectAll()
Dim wSheet As Worksheet
Dim Pwd As String
Pwd = InputBox("Enter your password to unprotect all worksheets", "Password Input")
If Pwd = vbNullString Then GoTo ExitPoint
On Error GoTo ExitPoint
For Each wSheet In Worksheets
wSheet.Unprotect Password:=Pwd
Next wSheet
ExitPoint:
If Err <> 0 Then
MsgBox "You have entered an incorect password. All worksheets could not " & _
"be unprotected.", vbCritical, "Incorect Password"
On Error GoTo -1: On Error GoTo 0: Err.Clear
End If
'Memory cleaning
Set wSheet = Nothing
Pwd = vbNullString
End Sub
Bookmarks