Macro Code Issue

  • Thread starter Thread starter uncbluegal
  • Start date Start date
U

uncbluegal

I've entered the following code within my excel document:

Sub UnlockAllSheets()
Const thePassword = "filepassword"
Dim anySheet As Worksheet
For Each anySheet In ThisWorkbook.Worksheets
anySheet.Unprotect Password:=thePassword
Next
End Sub

Sub LockAllSheets()
Const thePassword = "filepassword"
Dim anySheet As Worksheet
For Each anySheet In ThisWorkbook.Worksheets
anySheet.Protect Password:=thePassword
Next

End Sub


I have many locked and unlocked cells within this 13 worsheet workbook. I
can easily run either the unlock or lock macro - but - I'm never asked for
the password when I run either macro. Why is this?
 
The password is provided in the macros so won't get asked for it.


Gord Dibben MS Excel MVP
 
So how exactly then do I lock down and protect cells from being edited on
multiple spreadsheets?
 
Back
Top