How to protect / lock VBA code in Excel?
For Excel senior user, they always create some VBA codes to solve the complex problems. But, sometimes, they want to protect the VBA code from being viewed or destroyed by others. Just like you can use password to protect workbooks and worksheets, you can also set a password for protecting the macros in Excel.
Protect or lock VBA code in Excel
Protect or lock VBA code in Excel
To prevent others disabling your codes, the following steps can help you to set a password to protect the macros.
1. Press Alt + F11 keys to open your existing code, and in the Microsoft Visual Basic for Applications window, click Tools > VBAProject Properties, see screenshot:
2. In the VBAProject – Project Properties dialog box, please click Protection tab, and then check Lock project for viewing, finally, type and confirm the password that you want to protect the code in Password to view project Properties section, see screenshot:
3. And then click OK to exit the dialog, and close the Microsoft Visual Basic for Applications window.
4. Save the workbook as Excel Macro-Enabled Workbook format and close it to make the password protection take effect. Next time, when you open this workbook and try to view the code, you will be asked for the password to enter the code. See screenshot:
Related articles:
How to set a password to protect the workbook?
How to protect multiple worksheets at once in Excel?
How to recover lost worksheet protection password in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
