Method 1 – Perform a VBA Code to Unprotect Single Excel Sheet with Password in Excel
Step 1:
- Open a Module, to do that, firstly, from your Developer tab, go to,
Developer → Visual Basic
- After clicking on the Visual Basic ribbon, a window named Microsoft Visual Basic for Applications – Unprotect Excel sheet will instantly appear in front of you. From that window, insert a module for applying our VBA code. Go to,
Insert → Module
Step 2:
- A new module will be opened. In the module, write down the below VBA code.
Sub Unprotect_Excel_Sheet()
Sheets("VBA").Unprotect Password:="Exceldemy@0043"
End Sub
- Run the VBA. Go to,
Run → Run Sub/UserForm
- After running the VBA Code, you will be able to unprotect the Excel sheet named VBA with the password “Exceldemy@0043” which is given in the below screenshot.
- Check whether our unprotected Excel sheet will work or not. Select cell B15, and if you are able to write down anything in the selected cell, the unprotected Excel sheet will work which has been given in the below screenshot.
Method 2 – Unprotect Excel Sheet with Password Using VBA Code with Worksheet Name
Step 1:
- According to method 1, insert a new module and type the below VBA code to unprotect the Excel sheet with a password. The VBA code is,
Sub Unprotect_Excel_Sheet_with_Password()
Dim R As Worksheet
Set R = Worksheets("Unprotect")
R.Unprotect Password:="Exceldemy@0043"
End Sub
- Run the VBA To do that, go to,
Run → Run Sub/UserForm
Step 2:
- After running the VBA Code, you will be able to unprotect the Excel sheet named Unprotect with the password “Exceldemy@0043” which is given in the below screenshot.
Method 3 – Unprotect All Excel Sheets with Password Using VBA Code
Step 1:
- Insert a new module according to method 1 and type the below VBA code to change the font color. The VBA code is,
Sub Unprotect_All_Excel_Sheets()
Dim x As Worksheet
For Each x In Worksheets
x.Unprotect "Exceldemy"
Next x
End Sub
- Run the VBA To do that, go to,
Run → Run Sub/UserForm
Step 2:
- After running the VBA Code, you will be able to unprotect all Excel sheets.
- Check whether our unprotected Excel sheet will work or not. Select cell B15 in any of the Excel sheets, and if you are able to write down anything in the selected cell, the unprotected Excel sheet will work which has been given in the below screenshot.
Things to Remember
You can pop up the Microsoft Visual Basic for Applications window by pressing Alt + F11 simultaneously.
If a Developer tab is not visible in your ribbon, you can make it visible. To do that, go to,
File → Option → Customize Ribbon
Download Practice Workbook
Download this practice workbook to exercise while you are reading this article.
Related Article
- Excel VBA: Unprotect Workbook without Password
- Excel VBA: Protect Workbook with Password
- Excel VBA to Protect Sheet but Allow to Select Locked Cells