Excel sheet locked by password but never entered password before

Copper Contributor

When i open an unprotected excel file and try to edit the sheet, it pops out a window ask for password. I 100% sure that i never set up any protect sheet or other micro function things, just a very standard and normal excel file with standard use. And this happened to another two of my colleagues also. Can anyone help with? Thank you.

1 Reply

@TTTTL 

How to unprotect the excel sheet if forgot the password

 

 

Option Explicit

Sub GetPass()

    Const a = 65, b = 66, c = 32, d = 126

    Dim i#, j#, k#, l#, m#, n#, o#, p#, q#, r#, s#, t#

    With ActiveSheet

        If .ProtectContents Then

            On Error Resume Next

            For i = a To b

                For j = a To b

                    For k = a To b

                        For l = a To b

                            For m = a To b

                                For n = a To b

                                    For o = a To b

                                        For p = a To b

                                            For q = a To b

                                                For r = a To b

                                                    For s = a To b

                                                        For t = c To d

            .Unprotect Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr(n) & Chr(o) & Chr(p) & Chr(q) & Chr(r) & Chr(s) & Chr(t)

                                                        Next t

                                                    Next s

                                                Next r

                                            Next q

                                        Next p

                                    Next o

                                Next n

                            Next m

                        Next l

                    Next k

                Next j

            Next i

            MsgBox "Finished"

        End If

    End With

End Sub