Unprotect Excel Sheet Without Password Using VBA: 3 Simple Steps

We have a sheet VBA where we have some records of the products, and we have protected it with a password. unprotect Excel sheet VBA without passwordFor trying to make any changes, we are getting the following message. opening Visual Basic EditorTo unprotect this sheet with the help of a VBA code right-click on the sheet name and then select the View Code option. opening Visual Basic EditorThe Visual Basic Editor window will open up. opening Visual Basic Editor

Method 02 – Typing VBA Code to Unprotect Excel Sheet without Password

➤ Type the following code

Sub unprotect_without_pass() Dim digit1, digit2, digit3, digit4, digit5, digit6, _ digit7, digit8, digit9, digit10, digit11, digit12 As Integer If ActiveSheet.ProtectContents Then On Error Resume Next For digit1 = 65 To 66: For digit2 = 65 To 66: For digit3 = 65 To 66 For digit4 = 65 To 66: For digit5 = 65 To 66: For digit6 = 65 To 66 For digit7 = 65 To 66: For digit8 = 65 To 66: For digit9 = 65 To 66 For digit10 = 65 To 66: For digit11 = 65 To 66: For digit12 = 32 To 126 ActiveSheet.Unprotect Chr(digit1) & Chr(digit2) & Chr(digit3) & _ Chr(digit4) & Chr(digit5) & Chr(digit6) & Chr(digit7) & Chr(digit8) & _ Chr(digit9) & Chr(digit10) & Chr(digit11) & Chr(digit12) Next digit12: Next digit11: Next digit10: Next digit9: Next digit8: Next digit7 Next digit6: Next digit5: Next digit4: Next digit3: Next digit2: Next digit1 MsgBox "One usable password is " & Chr(digit1) & Chr(digit2) & _ Chr(digit3) & Chr(digit4) & Chr(digit5) & Chr(digit6) & Chr(digit7) & _ Chr(digit8) & Chr(digit9) & Chr(digit10) & Chr(digit11) & Chr(digit12) End If End Sub

unprotect Excel sheet VBA without password

We have declared digit1, digit2, digit3, digit4, digit5, digit6, digit7, digit8, digit9, digit10, digit11, and digit12 As Integer.
The IF-THEN statement will ensure if the sheet is protected or not and if it is protected then the following operation will continue. Then we have used 12 FOR-NEXT loops for assigning 12 ranges of values to our declared digits and these loops will work as nested loops to unprotect the sheet with the help of these digits and the CHR function will convert them to strings.
A message box (MsgBox) will appear with a randomly generated password with the help of this code.

Method 03 – Running Code to Unprotect Excel Sheet without Password

➤ Press F5.
This code will take some time to run.
The sheet will be unprotected with the following message box containing a randomly generated password. running codeWe can easily change the values of this dataset and convert Strawberry to Orange here. running codeOne thing to remember is that this code will require a lot of time to run. So, it is better to do this operation on a spare PC. Download Workbook

Unprotect Sheet.xlsm

Related Articles