I am locking and unlocking worksheets as needed, and when I lock the worksheet with VBA, the password validation screen comes up and asks for the password.
What am I missing to avoid the verification box and have the worksheet relocked at the end of the subroutine?
Sub LockAll()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
With Worksheets("SUPPLEMENTAL")
.Protect Password:="passwrod1"
.Protect DrawingObjects:=True
.Protect Contents:=True
.Protect Scenarios:=True
.Protect AllowFormattingCells:=False
.Protect AllowFormattingColumns:=False
.Protect AllowFormattingRows:=False
.Protect AllowInsertingCells:=False
.Protect AllowInsertingColumns:=False
.Protect AllowInsertingRows:=False
.Protect AllowDeletingCells:=False
.Protect AllowDeletingColumns:=False
.Protect AllowDeletingRows:=False
.Protect AllowInsertingHyperlinks:=False
.Protect AllowSorting:=False
.Protect AllowFiltering:=False
.Protect AllowUsingPivotTables:=False
.EnableSelection = xlUnlockedCells
End With
End Sub
Thanks in advance
sportsguy
Bookmarks