Macro Code Issue

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?
 
G

Gord Dibben

The password is provided in the macros so won't get asked for it.


Gord Dibben MS Excel MVP
 
U

uncbluegal

So how exactly then do I lock down and protect cells from being edited on
multiple spreadsheets?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top