Password Macro not working

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,727
Office Version
  1. 365
  2. 2019
  3. 2013
  4. 2007
Platform
  1. Windows
Hi All
I have the following macros for closing and opening numerous worksheets.
However, the Unlock macro asks for a password even though I haven't locked the sheets with one.
When the input box comes up for the password, I press enter and get the END, DEBUG error window.
If I press END the error message goes away and all of the sheets are unprotected.
Can anyone explain how I can get rid of the error message and Input box.
Sheets are only protected so I don't screw up the formulae, so a password isn't really necessary.

Kindest regards
Michael M

Sub SheetLock()
'
' SheetLock Macro
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In Worksheets
ws.Protect
Next ws
Application.ScreenUpdating = True
End Sub


Sub SheetUnLock()
'
' SheetUnLock Macro
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In Worksheets
ws.Unprotect
Next ws
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Your code seems OK to me.
I wonder if you have some posh new Excel version and need
Code:
ws.Unprotect Password:=""
 
Upvote 0
Hi Brian
Thanks for the response but......
No, not some posh version, just plain ole' Excel 2000.
I tried the code you mentioned as well, with the same result.
I can't for the life of me understand why it would ask for a password.
A friend suggested I save the file as a web page and then reopen it and save it back to Excel.
I have heard of this before, so will give it a try.

Regards
Michael
 
Upvote 0
Code:
Sub PasswordBreaker()
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 "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

ripped from this post

http://www.mrexcel.com/board2/viewtopic.php?t=159805&highlight=password+breaker
 
Upvote 0
Thanks Gibbs
I've got a password breaker from J E Mcgimpsey's site, which works really well.
Whilst this will work, I need to fix the problem, not band aid 'round it.
There is obviously something in my file that is screwing this up.
Maybe I should do a save as, remove all the modules and copy and paste the code back in !!
Regards
Michael
 
Upvote 0
I dunno, but Ihave two buttons set up on a toolbar which I use to protect/unprotect various files that only I have the password for. The password is hardcoded into the macro.

All of a sudden, my unprotect button where the password was identical stopped working. It could just be that excels password security is nearly useless since it does not even store the actual password, only the "hash" marks for each character.
 
Upvote 0
I know how you feel
My code doesn't even have a password !!!

I got some new code from a book called "Excel Hacks" by Hawley & Hawley.
Which doesn't need a password......and now that asks for a password as well!!

I'm stumped and frustrated.
Michael
 
Upvote 0
I just tied the password breaker into my unprotect button and tweaked it so that it either unprotects or on error goes to the password *******.

It is a royal pain though.
 
Upvote 0

Forum statistics

Threads
1,203,453
Messages
6,055,530
Members
444,794
Latest member
HSAL

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top