How to Password Protect Excel Macro Code and VBA Project
Applies to all Excel templates including: "Georges Budget for Excel", "Georges Excel Checkbook Register", "Georges Excel Checkbook for Mac"
(back to All Support Topics)
Why protect Excel macro code
Excel macros use VBA (Visual Basic for Applications) programming language to automate Excel tasks to save time and add additional functionality to Microsoft Excel. The macros are created and stored directly in the Excel file (Excel Workbook) using the Visual Basic Editor. Depending of what you are creating, code is stored in VBA modules, VBA user forms, VBA class modules and Microsoft Excel objects all of which make up the VBA project. To protect the code in the VBA project, you can require a password to view the VBA project. Depending on the complexity of the VBA project and the required security measures, you may want to require a password to view the VBA project so that only those with the password can access and change the contents of the VBA project and VBA code. For example, the VBA project for the Excel checkbook software (Georges Excel Checkbook Register / Georges Excel Checkbook for Mac) and Excel budget spreadsheet (Georges Budget for Excel) has been password protected to protect the copyrighted code and prevent and changes to it.
How to protect Excel macro code and vba project
In Excel 2007, Excel 2010, Excel 2013, Excel 2016, and Excel 2016 for Mac, to password protect your macros in the VBA project, click the Developer Tab in the Excel ribbon, the click Visual Basic command button to open the Visual Basic Editor. In the Visual Basic Editor click the Tools menu and then click VBAProject Properties. In the window that opens, click the Protection tab, and put a check mark next to Lock Project for Viewing, and then add and confirm a password to view project properties and then click OK. Save the Excel file. Then next time you open the Excel file and try to view the contents of the VBA project, it will require that you enter a password to view the VBA project.
When requiring a password, things to consider include:
- Complexity of password: Using strong passwords vs weak passwords
- Who gets a password
- Password safety
- Lost password: Microsoft does not recover lost VBA project passwords. BuyExcelTemplates.com does not recover lost passwords. If you loose your password, you will not be able to access the VBA code, unless you are able to recover the lost password.
Additional Excel protection and security tools
In addition to password protecting an Excel VBA project and macro code in the Excel file, there are additional ways to protect an Excel spreadsheet.
- Password protect an Excel file.
- Protect Excel workbook structure and windows.
- Protect Excel worksheet and cells.
(back to All Support Topics)