ChrisBurch
IS-IT--Management
I have a single sheet workbook, which is protected. When a button is clicked, I unprotect the sheet, do some work, then protect the sheet again.
This code works properly when I step it through in the VBA editor. However, when I run it from the button I get the following error:
Error 1004
Unprotect method of worksheet failed.
My code is:-
sub my-button ()
ActiveSheet.Unprotect "my_password"
Range("B4,B7,B13,F13,I13,A17:J44,G5,I5"
.Select
Selection.ClearContents
yada
yada
yada
ActiveSheet.Protect "my_password"
end sub
I have also tried this with the syntax, ActiveSheet.Unprotect password:="my_password" with the same results.
Can anyone suggest a fix?
Chris
It worked yesterday.
It doesn't work today.
That's Windows!
This code works properly when I step it through in the VBA editor. However, when I run it from the button I get the following error:
Error 1004
Unprotect method of worksheet failed.
My code is:-
sub my-button ()
ActiveSheet.Unprotect "my_password"
Range("B4,B7,B13,F13,I13,A17:J44,G5,I5"
Selection.ClearContents
yada
yada
yada
ActiveSheet.Protect "my_password"
end sub
I have also tried this with the syntax, ActiveSheet.Unprotect password:="my_password" with the same results.
Can anyone suggest a fix?
Chris
It worked yesterday.
It doesn't work today.
That's Windows!