shampouya
asked on
Dynamic password in Excel VBA
I was wondering how I can protect a worksheet with a password that changes every day, assuming a macro with the code below has run. How do I get the variable dateOfWeek to return a number from 1 to 7? And is it a bad idea to make a password slightly dynamic like that?
ActiveSheet.Protect Contents:=True, DrawingObjects:=True, UserInterfaceOnly:=True, Password:="mypassword" & dateOfWeek
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Have you considered using a GUID for your password?
Example:
Example:
strGUID = Mid(CreateObject("scriptlet.typelib").guid, 2, 36)
Let's say if you want to make it more dyanmic without dependent on dayofweek you can use this...
Open in new window
What rand between will do it will generate a random number between 1 to 10 even on the same day when you run the macro again so even on the same day your password will get changed...
Saurabh...