Forum Discussion

Train34's avatar
Train34
Copper Contributor
Jan 01, 2025

Forgot Excel password. Need to unprotect sheet

I need to unprotect my excel sheet and I've forgotten my password

  • Try this:

     

    1. Open your Excel file.
    2. Press Alt + F11 to open the Visual Basic for Applications (VBA) editor.
    3. Click Insert > Module to create a new module.
    4. Copy and paste the following code into the module window:
    5. Sub Unprotect_Sheet_without_Password()
          Dim x As Integer, y As Integer, z As Integer
          Dim a As Integer, b As Integer, c As Integer
          Dim x1 As Integer, x2 As Integer, x3 As Integer
          Dim x4 As Integer, x5 As Integer, x6 As Integer
          On Error Resume Next
          For x = 65 To 66: For y = 65 To 66: For z = 65 To 66
          For a = 65 To 66: For b = 65 To 66: For x1 = 65 To 66
          For x2 = 65 To 66: For x3 = 65 To 66: For x4 = 65 To 66
          For x5 = 65 To 66: For x6 = 65 To 66: For c = 32 To 126
              ActiveSheet.Unprotect Chr(x) & Chr(y) & Chr(z) & _
              Chr(a) & Chr(b) & Chr(x1) & Chr(x2) & Chr(x3) & _
              Chr(x4) & Chr(x5) & Chr(x6) & Chr(c)
              If ActiveSheet.ProtectContents = False Then
                  MsgBox "Password is " & Chr(x) & Chr(y) & _
                  Chr(z) & Chr(a) & Chr(b) & Chr(x1) & Chr(x2) & _
                  Chr(x3) & Chr(x4) & Chr(x5) & Chr(x6) & Chr(c)
                  Exit Sub
              End If
          Next: Next: Next: Next: Next: Next
          Next: Next: Next: Next: Next: Next
      End Sub

       

Resources