Protect/Lock Excel VBA Code

< Back to Search results

 Category: [Excel]  Demo Available 

Protect/Lock Excel VBA Code


Protect/Lock Visual Basic Editor (VBE)


Got any Excel Questions? Free Excel Help.


Protect/Lock Excel VBA Code

When we write VBA code it is often desired to have the VBA Macro code not visible to end-users. This is to protect your intellectual property and/or stop users messing about with your code. Just be aware that Excel's protection ability is far from what would be considered secure. There are also many VBA password recovery  for sale on the www.

To protect your code, open the Excel Workbook and go to Tools>Macro>Visual Basic Editor (Alt+F11). Now, from within the VBE go to Tools>VBAProject Properties and then click the Protection page tab and then check "Lock project from viewing" and then enter your password and again to confirm it. After doing this you must save, close & reopen the Workbook for the protection to take effect.

Protect VBA Macro Code

The safest passwords to use are ones that use a combination of upper, lower, numbers and text. Be sure to write it down though!


See also:

Excel VBA: Hide/Show Pivot Table Field Items
Printing PivotTables & PivotCharts
Refresh Pivot Table via VBA
Prevent Save As in Excel
Prevent Excel Being Saved With Another Name
Prevent Save Prompts in Excel
Excel VBA: Determine Number of Pages to be Printed


See also Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions.


Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


stars (0 Reviews)