• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro button is not working in a Protected page..

akinkaraman

Member
Macro button is not working in a Protected page.. Is there any solution to able the button in a Protected page?
 
In your code you have to Unprotect the worksheet
the reprotect it again when finished

You need something like this at the start:
Code:
SheetName.Unprotect Password:=yourPassword

And this at the end:
Code:
SheetName.Protect Password:=yourPassword
 
I am doing something wrong but I couldn't get it. It is crashing my Excel.

Could you please check my file?

The password of protected cells is 1234
 

Attachments

  • Clock.xlsm
    34.2 KB · Views: 2
Change the sub as shown below:
Code:
Sub Start_Clock()
With Sheets("Clock")
  .Unprotect Password:="1234"
  .Range("C3").Value2 = Now
  .Protect Password:="1234"
End With

dtime = Now + TimeSerial(0, 0, 1)
Application.OnTime dtime, "Start_Clock"
End Sub

or see attached
 

Attachments

  • Clock.xlsm
    31.9 KB · Views: 6
because you have asked it to update every 1 second

So every second it has to unprotect the worksheet
Update the time
Protect the worksheet
do other stuff

I'd try 2, 5 or 10 seconds
 
Back
Top