I have a workbook with the following macros:
The First macro password protects every sheet when the workbook is closed.
Const pw = "dashboard"
Sub Auto_Close()
Dim Wsht As Worksheet
For Each Wsht In Worksheets
Wsht.Protect Password:=pw
Next Wsht
End Sub
The second macro allows a user to unprotect all sheets at once.
Sub UnprotectAll()
ans = LCase(Application.InputBox("Enter password to continue"))
If ans <> LCase(pw) Then
MsgBox "Incorrect Password", vbExclamation, "Warning"
Exit Sub
End If
Dim Wsht As Worksheet
For Each Wsht In Worksheets
Wsht.Unprotect Password:=pw
Next Wsht
End Sub
I'm in Excel 2007. For every worksheet that has a pivot table, I receive a messagebox that says "Cannot edit PivotTable on protected sheet." when I open the workbook.
What's the best way to deal with this error?
Bookmarks