Thread: Command Button
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jordan Jordan is offline
external usenet poster
 
Posts: 144
Default Command Button

Jim, Thank you so much. It works perfect and unless the folks at my work are
perusing the discussion group, they are going to think I really know what I'm
doing.

Thanks again.

"Jim Thomlinson" wrote:

In XL show the Control Toolbox (Tools - Customize - Toolbars - Check
Control Toolbox). Drag a Button off the toolbar and place it on the sheet.
Right click the sheet tab and select view code. Paste the following code...

Private Sub CommandButton1_Click()

With ActiveSheet
If .ProtectContents = True Then
.Unprotect
CommandButton1.Caption = "Unprotected"
Else
.Protect
CommandButton1.Caption = "Protected"
End If
End With
End Sub
--
HTH...

Jim Thomlinson


"Jordan" wrote:

I would like to be able to protect a sheet if it currently is not protected
and unprotect the sheet if it is protected. I know how to record a macro and
I think I can figure out how to get it to work on a button, but I would need
two buttons.

I was wondering if it was possible to have one button that would check the
status and reverse it. Also, if it is possible how would I get the name on
the button to change?

Any help will be greatly appreciated. I don't know allot about programming
so talk real slow.