Don’t get excited, you can’t. There are no passwords in Excel that are truly secure, so if you need rock-solid security, Excel probably isn’t the tool for you. However, you can keep your code from casual prying eyes. In the Visual Basic Editor (VBE), right click your project and choose VBA Project Properties.
On the Protection tab, check the “Lock project for viewing” check box, type a password (twice) and you’re all set.
For the love of Pete, don’t forget your password. There are commercial password crackers available, but it’s a lot easier to remember it.
I lock all my projects for viewing if they will always be open (like Personal.xls and Add-ins) because if I don’t, all their code windows keep opening up when I start the VBE. I hate that, and protecting the code prevents it. I use the same password for all of them because I’m not really trying to protect them, just keep them out of the way.