The more you use macros the more important they become and the more you want to make sure the VBA* code doesn’t get changed by someone who shouldn’t change it. You may also want to stop people viewing your code.
Unfortunately the password security that I will describe below is not bullet-proof. It can be hacked. But it will stop most people from accessing or seeing your code.
In the VBA window (Alt + F11 to open).
1. In the Project Explorer on the left of screen Right Click the file you want to protect.
2. Click the VBAProject Properties option.
3. Click the Protection tab.
4. Make sure the Lock project for viewing option is ticked
5. Enter a Password and then enter the Confirm password (make sure you record the password somewhere!)
6. Click OK button to apply.
You need to save and close the file and then re-open it for the changes to take effect. Once the password has been entered you can view the code as per normal.
This will mean users will have to enter the password to see the code, even if they click Debug in a macro error dialog.
*VBA = Visual Basic for Applications – a macro programing language that is a subset of Visual Basic.