At the start of the code, use the InputBox function to ask the user to put in the password. Compare the returned string to the real password. If they aren't equal, execute the command Exit Sub.
To prevent users from simply opening the macro editor and reading the password from the code, apply a password to the code project (you'll find that in the macro editor's menu Tools > Properties > Protection). That password is very easy to break, but most users won't know that.
|