How to Unlock Vba Project Password in Excel
Excel VBA Project Password
Excel VBA Projection Password is a kind of tool in VBA which is used to protect the project code using the password. By this, we tin can protect the worksheet and the projects too. If nosotros protect the projection, in another way we are also protecting the Excel workbook likewise. We can either protect or preserve one project in VBA or multiple projects. And this is tin exist using the same procedure for both categories.
Usually, most of the code written in VBA has or requires merely a project in which all the worksheets, modules, user forms can exist seen.
How to Use VBA Project Countersign in VBA?
To protect the VBA Project using Password or to enable the password set in a VBA Projection, we will exist using the VBA Projection properties pick which is available in the Tools carte du jour bar in VBA as shown in the beneath steps. Then we will exist getting the VBA Projection properties window where we can set up the countersign whichever nosotros want, to protect the currently available projects in VBA.
You lot can download this VBA Project Password Excel Template hither –VBA Project Countersign Excel Template
Example #i
To employ a password in the VBA Project, first, nosotros need to have a code in a module. This could be any simple code equally per our selection or requirement. For this, follow the below steps:
Pace 1:
Insert a new module inside Visual Basic Editor (VBE). Click on Insert tab > select Module.
Step ii:
Now write the subprocedure for the VBA Project password.
Lawmaking:
Sub VBA_ProjectPW() End Sub
Pace 3:
Employ DIM to define a variable as an Integer.
Code:
Sub VBA_ProjectPW() Dim A As Integer Terminate Sub
Stride 4:
And last to close the code, use Debug print to print the value whichever could be stored in variable A. This is the simplest code that nosotros protect using the VBA Project password.
Code:
Sub VBA_ProjectPW() Dim A Every bit Integer Debug.Print A End Sub
Footstep v:
To exam this, we would run this lawmaking by pressing F5 or Play Push button is mentioned below the bill of fare bar.
Nosotros would notice that the code has run without whatever error. Now to protect the VBA Project with a password, go to Tools menu choice and select VBA Project properties as shown beneath.
Step six:
Nosotros will and then get the Projection Properties as shown beneath. And in that get to the Protection tab.
Step seven:
Now in the Protection tab’s Password and Confirm countersign section write the password which you want. Preferably the countersign should exist stiff plenty not be croaky hands by anyone.
Pace 8:
Nosotros take chosen the countersign as “Pa$$w0rd123” in the combination of Upper instance, lower example, special character, and numbers. The password should be the same in Countersign and Ostend Password section as shown beneath. It is better to re-create and paste the password to match and then Click on OK to leave.
Step 9:
At present relieve the lawmaking and and so close the VBA and Excel files. To check this, reopen the file. In the VBA window, we will encounter all the options like Modules in the VBA Project is subconscious. To test, click on the plus sign of the VBA Project.
Stride x:
Nosotros will get the password window at that place. To enter the password which we had called. And then click on Ok.
Footstep 11:
This would enable the VBA Project with all the options and we will be able to come across the lawmaking written in the module.
Step 12:
And if nosotros enter the incorrect password we would then go an incorrect message alert.
Example #ii
There is some other way to protect the VBA Projection using passwords with the assistance of code. For this, follow the below steps:
Footstep one:
In the same module and write the subprocedure.
Lawmaking:
Sub VBA_ProjectPW2() Terminate Sub
Step ii:
Now write define a variable using DIM equally a Variant.
Code:
Sub VBA_ProjectPW2() Dim Pw Equally Variant Cease Sub
Step 3:
In the defined variable Pw we will
utilise the Input Box application
and choose the title and bulletin which nosotros would like to come across.
Code:
Sub VBA_ProjectPW2() Dim PW As Variant PW = Application.InputBox("Enter Password", "Countersign Protected") Stop Sub
Step 4:
Open the Select Case-Else loop and there write the condition where if the entered password is “Pa$$w0rd123” then we would go the message every bit secured workbook in select range jail cell.
Code:
Sub VBA_ProjectPW2() Dim Prisoner of war As Variant Prisoner of war = Application.InputBox("Enter Password", "Password Protected") Select Case Pow Case Is = False Case Is = "Pa$$w0rd123" Range("A1").Value = "Workbook is secured." Case Else Cease Sub
Step 5:
And to meet if the entered countersign is incorrect then we would go a bulletin as Incorrect Password.
Lawmaking:
Sub VBA_ProjectPW2() Dim PW As Variant Prisoner of war = Awarding.InputBox("Enter Password", "Password Protected") Select Case PW Instance Is = False Case Is = "Pa$$w0rd123" Range("A1").Value = "Workbook is secured." Instance Else MsgBox "Incorrect Countersign" Terminate Select Stop Sub
Pace half-dozen:
At present if we run the lawmaking by pressing F5 or the Play Button is mentioned beneath the carte du jour bar, we would get the Password Protected window where nosotros would enter the countersign. If the password entered is correct and so this window volition exist closed.
Footstep vii:
One time entered, click on Ok.
Stride eight:
We would run across the code has run successfully. And the cell A1 would have the bulletin which chose in VBA Code as “Workbook is secured.”
Pros of VBA Project Password
- This is helpful is securing the very confidential code which we probably practice non want to evidence to anyone.
- VBA Project protected using the methods which nosotros have seen in the in a higher place examples is best to secure the lawmaking.
Things to Remember
- Password entered using VBA Project Password can be cracked using the alternate add-ins available and can be downloaded from the internet or Microsoft website.
- Make sure the password entered is easy to enter, like shooting fish in a barrel to recollect. Or else keep the annotation and so that it is not lost. If by any risk the entered password is incorrect then it is hard to recover information technology.
- If the excel is not saved in the format of Macro Enable format then the written lawmaking volition be lost.
- VBA Project Password is different from the method of protecting the Excel file using Protect Sheet, Protect Workbook available in Review carte du jour bar.
Recommended Articles
This is a guide to the VBA Projection Password. Here we discuss how to protect the project code using the password in excel VBA along with practical examples and a downloadable excel template. Yous can as well become through our other suggested articles –
- How to Use VBA Login?
- VBA Month | Examples With Excel Template
- How to Utilize Create Object Function in VBA Excel?
- How to Use VBA IsError Part?