In the VBA Editor, go to the Tools menu, choose VBA Project Properties and
then the Protection tab. There, check "Lock project for viewing" and assign
a password.
Do note, however, that the password protection is notoriously weak. I use
VBAKey from Passware and can get into any VBA project in a matter of 2 or 3
seconds. If your code has propriety or other value, you would be MUCH
better off taking the code out of the workbook and putting it into a COM
Add-In. Since a COM Add-In is compiled to machine code as a DLL and you
distribute only the DLL to the end users, source code is never distributed
so security/password protection is not an issue.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)