Password Protect Excel VBA Macros

Add to Favorites

How to password protect VBA code and macros in Excel so that a user cannot see the code or edit it or do anything to it at all.

This allows you to safely secure your VBA code and prevent users from tampering with it or even seeing it.

Steps to Password Protect VBA Code/Macros

  1. Go to the VBA Editor window by hitting Alt  + F11
    d42e890b8c8c6e19fadbf32259244996.jpg
  2. Right-click the desired project from the left side of the window and then click VBAProject Properties...
    85f6053a876780a18aebdaec80d33c75.jpg
    OR go to Tools > VBAProject Properties...
    c5e379bc9e080ae0760f1c35681dfe9b.jpg
  3. In the window that opens, go to the Protection tab and check next to where it says Lock project for viewing and then enter a password.
    258ba4afef16a57eec223241d44a13e5.png
  4. Hit OK, save the file, close it, and that's it!

Now, whenever you go to open the file and view the code again, the window will look like this:

83ebe49f2de6f3fde70fa9f38fabac85.jpg

And, when you try to expand the project, a window opens for you to enter the password.

68e996e3e7f3531105c1e81209aef374.png

You now can't do anything with this project unless you have the password for it.

Notes

DO NOT LOSE YOUR PASSWORD!

DO NOT ASK US FOR HELP OPENING A PASSWORD PROTECTED FILE OR PROJECT!

Download the sample file to see this feature in action; the password for this is 123456 (PLEASE don't ever use that as a real password for anything, this was done here just to keep things simple for you).


Downloadable Files: Excel File

Similar Content on TeachExcel
Password Protect Excel Files
Tutorial: How to keep an Excel workbook safe by encrypting it with a password. This will make it so ...
Logical Operators in Excel VBA Macros
Tutorial: Logical operators in VBA allow you to make decisions when certain conditions are met. They...
Loop through a Range of Cells in Excel VBA/Macros
Tutorial: How to use VBA/Macros to iterate through each cell in a range, either a row, a column, or ...
How to Add a New Line to a Message Box (MsgBox) in Excel VBA Macros
Tutorial: I'll show you how to create a message box popup window in Excel that contains text on mult...
Excel VBA - Create an Array - 3 ways
Tutorial: Ill show you three different ways to create an array in Excel VBA and Macros and how to ge...
Loop Through an Array in Excel VBA Macros
Tutorial: I'll show you how to loop through an array in VBA and macros in Excel.  This is a fairly ...
Tutorial Details
Downloadable Files: Excel File
Similar Content
Password Protect Excel Files
Tutorial: How to keep an Excel workbook safe by encrypting it with a password. This will make it so ...
Logical Operators in Excel VBA Macros
Tutorial: Logical operators in VBA allow you to make decisions when certain conditions are met. They...
Loop through a Range of Cells in Excel VBA/Macros
Tutorial: How to use VBA/Macros to iterate through each cell in a range, either a row, a column, or ...
Excel Forum