Hi, vlady,
you would need to store the password (in the CustomProperties of the workbook, a name, a range in a hidden sheet, a text file, the registry) in order to rely on these. You may even put that password into the code but I prefer not to do so but keep it away. Also check the length of the password and assign a value to it if it is still 0.
In your second code you protect with a given password. Please make sure to assign that password to your variables as well.
Ciao,
Holger
Bookmarks