How to Password Protect VBA Codes in Your Excel Worksheet

Except for setting passwords for your Excel files and worksheets, now you can also password protect VBA codes. In this article, we will show you the method to fulfill this task.

VBA codes in a macro-enabled workbook are certainly very essential to your work. Hence, you need to protect those codes. Among all the protection methods, you can set passwords for the codes. And below are the steps about this task.

Protect VBA Codes

  1. Open the target file that contains the VBA codes that you need to protect.
  2. Click the tab “Developer” in the toolbar.
  3. And then click the button “Visual Basic” in the toolbar. Thus, you have activated the Visual Basic editor. In addition, you can also press the shortcut keys “Alt +F11” on the keyboard to activate the editor.Visual Basic
  4. Next in the editor, click the button “Tools” in the toolbar.
  5. And then choose the option “VBAProject Properties” in the sub menu.VBAProject Properties
  6. Now in the “Project Properties” window, choose the tab “Protection”.
  7. Next check the option “Lock project for viewing”.
  8. After that, input your password into the text box of the “Password”.
  9. And then input the password again into the text box of the “Confirm password”.Set Password
  10. When you finish all the settings, click the button “OK”.
  11. After that, click the button “Save” in the toolbar. Or you can also press the “Ctrl + S” on the keyboard to save the file. Thus, you have saves the password in the file.

Save

The Effect of the Setting

Here we will show you the effect of the setting.

  1. Now close the current file and then open it again.
  2. Next open the Visual Basic editor. Here you cannot see the codes directly.Invisible Codes
  3. When you try to expand the menu and watch the codes, you will see the “VBAProject Password” window pop up.
  4. Now input the password into the text box.
  5. And then click the button “OK”.Input Password

Thus, you can expand the menu and see all the codes in the project.

In addition, there still exists another result. In the previous part, if you uncheck the option “Lock project for viewing” in step 7, the result will be a little different. When you open the Excel workbook, you can still see the codes in the project. The difference lies in the VBAProject Properties.

  1. Click the button “Tool” in the toolbar.
  2. And then click the option “VBAProject Properties”.VBAProject Properties

And now, instead of opening the dialog, you will see the “VBAProject Password” window pop up.Input Password

  1. Here input the password and click “OK”. Thus, you can check the project properties.

Therefore, if you need other users to know the codes and hide the properties, you can uncheck the option “Lock project for viewing”. The settings are all depend on your need.

Remove Passwords

When you want to remove passwords from the VBA projects, you may also follow the steps below.

  1. Open the project properties window.
  2. And then click the tab “Protection”.
  3. Next clear all the settings in the window.Remove Password
  4. After that, click the button “OK”. And now, you have removed the password from the project. And the next time, you can directly check the codes and properties in the editor.

Encrypt Your Essential Excel Files

There are certainly some mission-critical Excel files in your computer. You need to protect those files and keep them safe. However, even if you have encrypted your essential Excel files, you still have the chance to suffer from data disaster. Even if you use a very potent encryption method, certain hackers own the ways of decryption. To repair Excel errors, you can seek to our qualified programmer for help. With years of experience, you are sure to get a satisfactory answer.

Author Introduction:

Anna Ma is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair docx data damage and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.