View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
bhofsetz[_82_] bhofsetz[_82_] is offline
external usenet poster
 
Posts: 1
Default Toggle command buttons


If the buttons are from the control toolbox then the code would be
placed on the code window behind the worksheet on which the buttons
reside.

You can get the buttons to 'toggle' with the following code


Code:
--------------------
Private Sub CommandButton1_Click()
CommandButton1.Enabled = False
CommandButton2.Enabled = True
'Your code here
End Sub

Private Sub CommandButton2_Click()
CommandButton2.Enabled = False
CommandButton1.Enabled = True
'Your code here
End Sub
--------------------


You could also use a single button and have it's caption change with
each click and then the action taken depend on the value of the
caption.


Code:
--------------------
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "Analysis" Then
CommandButton1.Caption = "Clear"
'your analysis code here
Exit Sub
End If
If CommandButton1.Caption = "Clear" Then
CommandButton1.Caption = "Analysis"
'your clear code here
Exit Sub
End If
End Sub
--------------------


HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381663