Recovers Password Protected Worksheet and Not Workbook
Remember the code in this page will help you to generate an alternate password, if you have forgotten your password and use Microsoft Sheet.Unprotect Method. The generated password can be supplied to unlock Excel Worksheet if it is locked or protected for editing.
This method does not allow you to recover or crack a password protect Excel Workbook. Do not use it to on Excel Files that you are not authorized to open.
This method is explained here to educate that there is an easy way to unprotect locked Excel sheet just with few lines of Excel Macro coding. If you really want to keep your Excel files so safe, then use the methods explained in another article in this site.
UnProtect Excel Sheet Without Password
This code is not something that I invented. It is all over the Internet, but still many People use this method of Protecting a Sheet with a password. You can use this Worksheet Protection password, only to prevent accidental updates happening to an Excel Workbook.
If you want to completely stop un-authorized access to a Excel File, then use complete encryption provided by Microsoft as discussed in this page. The Code in this page is a very good learning to know how exact password is not used to lock your sheet. Only hash table is used. Google about it to understand more on this.
Protect Excel Worksheet From Editing With Password
To test whether this code works or not lets create a Excel & Protect it with a Password as in following steps:
- Create a New Excel workbook.
- Type some data in Sheet1 in any cell.
- Go to Menu -> Review -> Protect Sheet.
- A Pop-up Window will appear. Enter a Password and Click ok. Double confirm password.
- Now, If you type any data in Sheet, Excel will give you a warning message saying that the Sheet is protected from Editing.
That’s it. We have protected the Excel Sheet from Editing. Assume, we have forgot the password. What do we do then?
Recover Excel Sheet Password to Unlock Editing
In the same sheet, press Alt + F11 to get the VB Editor. Copy paste the below code in the VBE. Press F5 to execute the code.
This code will generate alternate password combination to unlock the sheet. Once it succeeds, the loop will terminate and will provide you an alternate password.
12345678910111213141516171819202122232425262728Option ExplicitSub UnProtect_Excel_WorkSheet()'Unlock Protect Excel WorksheetDim i1 As Integer, i2 As Integer, i3 As Integer, j1 As Integer, j2 As Integer, j3 As IntegerDim k1 As Integer, k2 As Integer, k3 As Integer, l1 As Integer, l2 As Integer, l3 As IntegerDim a As DoubleOn Error Resume Nexta = 0'Try all Possible Alternate Combination PasswordFor i1 = 65 To 66: For i2 = 65 To 66: For i3 = 65 To 66For j1 = 65 To 66: For j2 = 65 To 66: For j3 = 65 To 66For k1 = 65 To 66: For k2 = 65 To 66: For k3 = 65 To 66For l1 = 65 To 66: For l2 = 65 To 66: For l3 = 32 To 126ThisWorkbook.Sheets(1).Unprotect Chr(i1) & Chr(i2) & Chr(i3) & Chr(j1) & Chr(j2) & Chr(j3) & Chr(k1) & Chr(k2) & Chr(k3) & Chr(l1) & Chr(l2) & Chr(l3)a = a + 1ThisWorkbook.Sheets(2).Cells(a, 1) = Chr(i1) & Chr(i2) & Chr(i3) & Chr(j1) & Chr(j2) & Chr(j3) & Chr(k1) & Chr(k2) & Chr(k3) & Chr(l1) & Chr(l2) & Chr(l3)'Check if the Protection is RemovedIf ActiveSheet.ProtectContents = False ThenMsgBox "One usable password is " & Chr(i1) & Chr(i2) & Chr(i3) & Chr(j1) & Chr(j2) & Chr(j3) & Chr(k1) & Chr(k2) & Chr(k3) & Chr(l1) & Chr(l2) & Chr(l3)Exit SubEnd If'Exit LoopNext: Next: Next: Next: Next: NextNext: Next: Next: Next: Next: NextEnd Sub
Try to enter any data into sheet now. The warning message will not occur now. Microsoft has provided an option to lock and unlock worksheets from editing as an additional flexibility for VBA developers. So, it is advised not to use this code to exploit or crack or hack password protected Excel Sheet data from other users, for which you are not authorized.
UnLock Protected Excel Worksheet Without Knowing Its Password
Top5 Trending Posts