Hi All, I have a worksheet that is unlocked by VBA to run some code, and then locked again. The password is based on a value in a cell on another worksheet. When I want to unlock manually, I get an error message that the supplied password is incorrect. If I run the code again, it works correctly. If I remark out the second "protect" line of code, the sheet remains unlocked. If I set the password manually and then change the password in the code to the same one, it runs correctly but if I try and unlock it manually, it doesn't work again. I can't figure out what's going on. The code is:
VBA Code:
Dim pw As String
pw = Sheets("Release").Range("A20").Value
-code here-
Sheets("Data").Unprotect Password = pw
-more code here-
Sheets("Data").Protect Password = pw