How To Password Protect Your VBA Code

Sometime back we wrote a blog post explaining how to password protect excel workbook. Few of our readers wrote us a query that they don’t want to password protect the entire workbook but only the VBA code so that no one can edit it. So we thought it would be a good idea to share the steps to password protect the VBA Code with rest of our readers also.

Step 1: To make VBA code password protected, launch the VB Editor (Alt+F11) and select the project in the Project Explorer window.

Step 2: Choose Tools -> VBAProject Properties as shown in the figure below:

Select VBAProject PropertiesStep 3: Selecting VBAProject Properties will launch Project Properties dialog as shown in the figure below. Select “Protection” tab.

Enable the “Lock project for Viewing” check box and enter a password twice. Click OK and then save your file.

Password Protect VBA Code in ExcelWhen the file is closed and reopened, a password will be required to view or modify the code. Please note that unless the file is closed and re-opened, password protection will not work.

Hope you find the information presented here useful. Feel free to leave your queries or feedback in the comments section below.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">