how to make

n00b

New Member
Joined
Feb 17, 2002
Messages
18
a button so that when it is [ress it will protect the sheet, and press again to unprotect the sheet?
also is it possible so that after the sheet is protected the button text will say "click unprotect sheet" and when it is pressed again it will say " click to protect sheet"
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi,

If you place the commandbutton on your sheet and change it's caption to Click to Protect Sheet. Then double click the button and use this code:-

Code:
Private Sub CommandButton1_Click()
If Me.CommandButton1.Caption = "Click to protect sheet" Then
    Me.Protect "passwordIfyouwant"
    Me.CommandButton1.Caption = "Click to unprotect sheet"
Else
    Me.Unprotect "passwordIfyouwant"
    Me.CommandButton1.Caption = "Click to protect sheet"
End If
End Sub

HTH,
D
This message was edited by dk on 2002-02-25 07:18
This message was edited by dk on 2002-02-25 07:19
 
Upvote 0
Are you using the command button from View, Toolbars, Control Toolbox? If you place that button on the sheet and make sure you're in Design mode (the blue set square icon on the Control Toolbox is pressed in). Now double click the button. It will take you to the code module of the button's parent - in this case the sheet code module. Put the code there - not in a standard module.

Any more problems, let me know,

Regards,
D
 
Upvote 0

Forum statistics

Threads
1,223,315
Messages
6,171,410
Members
452,399
Latest member
oranges

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