I have three macros in my workbook that work fine. However, when I protect any of the worksheets, they stop to work and I get a run-time error 1004
.
I
help for macro beginners:
if you are using a button to run a macro, include the following inside sub buttonclick()
Dim sh As Worksheet
Dim yourPassword As String
yourPassword = "whatever password you like"
For Each sh In ActiveWorkbook.Worksheets
sh.Unprotect Password:=yourPassword
"now enter your macro which needs to be run
,at the end , before end sub paste the below line
For Each sh In ActiveWorkbook.Worksheets
sh.Protect Password:=yourPassword
Next sh