Document

How to Password Protect My VBA Code in an Excel Sheet

Summary: This article tells you all about VBA project password protection. It is useful for those who want their Excel file secure and don’t want other people to gain access without permission. We’ll discuss the password protection’s limits as well.

Protect Your VBA Macros with This Trick

Problem: I don’t want anyone to access my Excel sheet and edit or change any of the macro code that’s placed in it. What can I do?

How: There is a very simple solution for the above problem. Password protect your VBA project in Excel to prevent unauthorized changes (see screenshots below).

This also works for other Microsoft Office applications such as Access, Word, etc.

Step 1. Open the Microsoft Excel workbook that contains your VBA project.

Step 2. Press Alt+F11 to open the Microsoft Visual Basic for Applications window.

Or you can press the “Developer” tab > “Visual Basic” button.

Open Visual Basic for Applications Window in Excel

Step 3. In the opened Microsoft Visual Basic for Applications window, go to “Tools” > “VBAProject Properties”.

Excel Tools VBAProject Properties

Step 4. In the “VBAProject” dialog box that appears, click on “Protection” in the right column and check the “Lock project for viewing” option.

Now type a password in the textbox below this option and re-type it to confirm. Then hit “OK” to close.

Excel VBA Lock Project for Viewing Enter Password
VBA password protection is a security feature in Excel

Keep this password handy! You will need it to open your Excel VBA project.

Step 5. You can now shut the Microsoft Visual Basic for Applications window. After that, click the “Save” button in the upper left corner of Excel. Then close the Excel workbook.

That’s it. This is how you password protect your VBA project in Excel.

We advise that you re-open the Excel workbook to ensure that the VBA project is properly secured.

Excel Workbook VBA Code is Now Password-Protected

If you want to unlock your VBA project, simply remove the password protection and hit “Save” again to update the changes.

VBA Password Protection and Its Limitations

Although your VBA code is now sealed with a password, there are drawbacks to this method—It can’t prevent people from accessing your project who truly want to do so.

Someone may still access your Excel workbook without knowing the password. For example, VBA password removers can decrypt your file and reset your password. A quick search will show that there are several such tools available on the market, both commercial and free.

Yes, password protection is very useful for most people who don’t want unauthorized changes to their code. However, you should be aware of its limitations if you’re using it to protect sensitive data or intellectual property. So in order to safeguard your VBA code more effectively in Excel, the best solution is to convert it to a C/C++ file. You may discover many more options for protecting your VBA code from the link.

Susanna

Susanna is the content manager and writer of Filelem. She has been an experienced editor and book layout designer for many years, and interested in trying and testing various productivity software. She is also a huge fan of Kindle, who has been using Kindle Touch for nearly 7 years and carrying Kindle almost wherever she goes. Not long ago the device was at the end of its life so Susanna happily bought a Kindle Oasis.

Related Articles

Back to top button