VBA Project Password / Protect VBA code

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on March 15, 2024

This article will explain how to password protect your VBA projects.

vba password msgbox

When you create a custom VBA add-in or series of macros for a user, you might like to protect your intellectual copyright, or that of our company’s, by password protecting your code so that it is more difficult to copy (Note: VBA Protection is very easy to get around. You should not rely on this security.). Alternatively, you may simply wish to protect your code so that it can’t be easily changed.

Add Password to VBA Project

  1. In the VBE Editor, Select the VBA Project you wish to protect in the Project Explorer.

VBA 17 PIC 01

2. Right-click on the Project Name, and then click on Properties in the shortcut menu.

VBA 17 PIC 02


  1. Click on the Tools menu, and click on the Properties

VBA 17 PIC 03

  1. Click on the Protection tab

VBA 17 PIC 04


  1. Check the “Lock project for viewing” tick box, and then type in the password you wish to use to lock the project.

VBA 17 PIC 05

6. Re-type the password in the Confirm Password box, and click OK.

7. Save your file.

8. Close your File, and then re-Open it again.

9. Press F11 to go to the VBE.

10. You will notice that you cannot see any of the forms or modules

VBA 17 PIC 06

11. Click on the plus-sign to the left of your project name.

VBA 17 PIC 07

12. Type in your password to enable you to view your modules and forms.

VBA 17 PIC 08

Remove Password Protection from VBA Project

  1. Right-click on your VBA Project and select the project Properties, or go to the Tools menu and select the Properties option.
  2. Select the Protection tab, and un-check the “Lock project for viewing” check box.
  3. Click OK.

VBA 17 PIC 09

4. Remove your password from the Password and Confirm password

TIP: if you do not remove the password, the Project will be unlocked and the modules and code will be able to be viewed, but you will still need the password to go into the project properties.

  1. Save your file.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as

Learn More!

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples