Password Protect Excel VBA Macros

Add to Favorites
Author:

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

Question? Ask it in our Excel Forum


Our Excel Courses

  • Skill Level: All Levels
  • |
  • 5 hours+

How to make a fully featured professional form in Excel that is unbreakable. This includes how to use the form to store, view, edit, and delete data from a data storage worksheet.

  • Skill Level: All Levels
  • |
  • 2 hours

Send Emails from Excel using VBA and Macros. This course starts from the Basics and builds up to more advanced examples with attaching workbooks, worksheets, PDF's, automatically sending emails, including a signature, error handling, increasing speed, and more.

Similar Content on TeachExcel
Login to a Website using a Macro
: Connect and login to a website using a macro in Excel. This allows you to open a website a...
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...
Require a Password to View Hidden Worksheets in Excel - VBA Tutorial
Tutorial: Full Course A simple macro that allows you to require a password in order to view hidden ...
Tutorial Details
Downloadable Files: Excel File
Similar Content
Login to a Website using a Macro
: Connect and login to a website using a macro in Excel. This allows you to open a website a...
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...
Excel Forum