Protecting Command Button

krishnaa_kumarr88
2StarLounger
Posts: 179
Joined: 30 Sep 2014, 15:18

Protecting Command Button

Post by krishnaa_kumarr88 »

Hi all,
I would like to protect only the buttons on my sheet, I do not want to protect/lock the sheet I only want to keep users from accidentally changing or moving the button. When I tried protecting the sheet even with all the cells unlock the macro would not work. Thanks
I am using both Form control and ActiveX control in my sheet.
Any idea guys?

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Protecting Command Button

Post by HansV »

If you run your macro while the sheet is protected, what is the error message?

You might unprotect the sheet at the beginning of the macro, and protect it again at the end:

Code: Select all

Sub MyMacro()
    ActiveSheet.Unprotect Password:="secret"
    ' Your actions here
    ...
    ActiveSheet.Protect Password:="secret"
End Sub
Substitute the correct password (if you don't use a password, omit the part Password:="secret").
Best wishes,
Hans

krishnaa_kumarr88
2StarLounger
Posts: 179
Joined: 30 Sep 2014, 15:18

Re: Protecting Command Button

Post by krishnaa_kumarr88 »

I have both Form control and ActiveX control in my same sheet . I would like to lock only those two command button but not the complete sheet.

Is it possible ?

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Protecting Command Button

Post by HansV »

No, I don't think so.
Best wishes,
Hans

krishnaa_kumarr88
2StarLounger
Posts: 179
Joined: 30 Sep 2014, 15:18

Re: Protecting Command Button

Post by krishnaa_kumarr88 »

Thanks :)