How to unprotect the excel sheet if forgot the password

Copper Contributor

Hi team need support to unprotect my sheet which is password protected and forgot the password

 

304 Replies

@NikolinoDE 

where can I send the workbook for you to unprotect it? 

Amazingly its worked very smart. I've another workbook that does not have macro enable file.  but it have password and how this code work on that file. Because there is no module insert option.  @NikolinoDE 

Having some real problems with getting this to work. Deleted all the extra spaces and it would at least start with the spinning thing but it never finishes. Made a very small two sheet Excel file with very little info and password protected it (as a test). Opened up VBA, selected sheet 1 and copied the code into the window. What should the two drop down windows at the top be set at?  They default to "(General)" and "GetPass".  And "Option Explicit" is above a line at the top- is that OK?  I feel like a tiny file like my test one should un-protect in no time but maybe I'm wrong.

This procedure- the zip file one- doesn't work for me either.

@Valvashon 

 

Here is the link that explains it in detail:  Password options

 

Step by step what we need to do to unlock it.

  1. Open the Excel file we want to unlock.
  2. We go to the desired worksheet.
  3. Press Alt + F11 to open Visual Basic.
  4. Press F7 to bring up the code editor.
  5. Copy the following code:

 

Sub OpenSesame()

    Dim i As Integer, j As Integer, k As Integer
    Dim l As Integer, m As Integer, n As Integer
    Dim i1 As Integer, i2 As Integer, i3 As Integer
    Dim i4 As Integer, i5 As Integer, i6 As Integer
    On Error Resume Next
    For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
    For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
    For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
    For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
    ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _
        Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
        Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
    If ActiveSheet.ProtectContents = False Then
        MsgBox "NikolinoDE: One usable password is " & Chr(i) & Chr(j) & _
            Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
            Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
         Exit Sub
    End If
    Next: Next: Next: Next: Next: Next
    Next: Next: Next: Next: Next: Next
End Sub

 

6. Press F5 to run the code.

7. The worksheet will be unlocked.

 

Here is the link again:  Password options

Using a password code remover means you have the proper right to have permission from the Excel file owner to access the protected content and/or unlock the worksheet(s). No one but you is liable for the illegal use of the manual.

 

Hope I was able to help you with this info.

NikolinoDE

I know I don't know anything (Socrates)

I tried to remove the password with the Visual Basic Editor (VBE) process multiple times with the two different code strings in the above thread and was never able to do it.
I decided to click on the "Password Options" link above and it took me to a procedure that finally worked! It's very easy and super quick.
As a Mac user I will detail the steps I used to help other Mac users stuck using Windows or others who may not be tech savvy. This was on a Windows 10 Home system. Always practice or work on a copy of your file to avoid data loss:
1- search for and download a program called "7zip". Open that program.
2- Find the Excel file that you wish to remove the worksheet password from.
3- Right click on the file then open "properties" from the pop-up box
4- At the top you will see the file name. Change the extension to "7z".
5- Hit "OK" then verify that you want to change the extension.
6- Right click again, then select "7-Zip" toward the top. Select the top "Open Archive" option.
7- Your file will be extracted in the new box that pops up.
8- Open "xl" file, then open "worksheets" file
9- Your Excel file document worksheets will be displayed individually.
10- Right click on the first sheet you wish to remove the password from.
11- Click where it says "view" or hit "F3"
12- Your sheet will open in "Notepad" and display a lot of code.
13- Go to "Edit" and then "Find". Type in "protection". Make sure "Match Case" is not checked.
14- You should see this phrase- "sheetProtection". If so, you have found what you need to delete.
15- Highlight starting here: <sheetProtection... all the way through to the closing caret in this code.
16- Your highlighted code should include a caret (<) at the start and end (>) and no carets inside of the highlighted text. Delete this text, removing the sheet protection.
17- Select File and then Save, then close that window.
18- Hit "OK" when asked to update it in the archiver
19- Do the same thing with any other sheets that have been protected.
20- When done, close the window with the sheets.
21- Right click on the file you are modifying and select "Properties" again.
22- Change extension back to ".xlsx" and acknowledge the change.
23- Double click on your file. It should open in Excel with the worksheet password removed from the selected sheets.
Worksheets can be opened with .zip whether Mac or windows. It has been described several times in this post, forum and internet. However, you can never open a locked Excel file with it.
I'm not describing trying to open a "locked" file but rather a file that has protection on the worksheets, in my case, protected cells in that sheet. The thing that finally worked for me was to use 7-Zip as it was the program that produced step 18 above, asking to update it in the archiver. The other zip programs I used did not ask about updating the archiver and did not do so, meaning that I could take out code all day long and it wouldn't un-protect that worksheet.
That's an important step that needs to be pointed out. With the other zip programs you can feel like you are doing everything right yet you are getting no indication that your files are not being updated.

@Valvashon 

Everything is OK! You have described the steps very nicely.

Just wanted to make it clear, also for the other users, that this is about unlocking worksheets and not files. This is very often confused and many users have read and are reading this message (not only your post :).

Other steps and methods are required to open files, such as brute force, and if the files are Excel 2016 or later, the chances of success are very low.

Here again the note from Microsoft itself:  Microsoft informs

 

I wish you continued success with Microsoft Excel!

 

NikolinoDE

I know I don't know anything (Socrates)

@NikolinoDE 

Tried running the code but it ends in Syntax error. Any clues?

 

Thanks

@NikolinoDEneed your assistance please 

Mitch00390_0-1682931225262.png

 

 

@NikolinoDE 

I forgot a password to an excel file. So I cannot open the file at all. Is there anyway to remove the password from the file to be able to open it?

@loporreca 

The answer depends on the version of your file format. If it's a version with a 40-bit encryption key, it can be decrypted without a password. If it's Excel 2003 or later, the only option is to attempt a brute-force search for the correct password. The success of this method depends on the complexity of the password and your knowledge of it (such as using dictionary mutations or positional masks). You can find more details on this topic if you're interested.

@NikolinoDE 

 

Need to remove the empty line after .Unprotect ......  Compiler looking for code contiunation on next line!

 

Should be .Unprotect ...........Chr(m) & _

                     Chr(n)..................

 

not ...................Chr(m) & _

 

                Chr(n).................................................................

.Unprotect Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & _ this code reflects error message on VB
Remove the blank line (underscore "_") at the end.

@NikolinoDE 

Hi! can ou please help with this file? the tab is 2023 locked worksheet. Is it possible to find out what password was?

 

@NikolinoDE 

 hello, sir I read your comment on how to unlock your Excel workbook but I could not do that. sir, I want your help could you please unlock my Excel workbook? I need your email so that I send you my Excel sheet. I hope you will help me. 

@NikolinoDE 

 

unable to do coding .... can I send you the file to unlocck?

@NikolinoDE 

 

Hi, thank you for being so helpful in the forum. I have used the same password for a number of iterations of my personal excel sheet. And now it has stopped working. I have used the same password for 4 years, so I really doubt that I am typing in the wrong password. 

I have seen your helpful code promts but I am not technical enough to repeat these processes. Any thoughts what I can do. Would prefer not to send the password out if possible. :(