Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle command buttons
I have an "Analysis" and a "Clear" button.
At first I only want the "Analysis" button to be active and the "Clear" button disabled. After the "Analysis" button is clicked I want the reverse, and so on (toggle). I didn't see any code window for the controls. How can I code this? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle command buttons
Where did you get the controls from the Forms toolbar or the control
toolbox. -- HTH Bob Phillips "GEB" wrote in message ... I have an "Analysis" and a "Clear" button. At first I only want the "Analysis" button to be active and the "Clear" button disabled. After the "Analysis" button is clicked I want the reverse, and so on (toggle). I didn't see any code window for the controls. How can I code this? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle command buttons
From the Forms toolbar.
"Bob Phillips" wrote: Where did you get the controls from the Forms toolbar or the control toolbox. -- HTH Bob Phillips "GEB" wrote in message ... I have an "Analysis" and a "Clear" button. At first I only want the "Analysis" button to be active and the "Clear" button disabled. After the "Analysis" button is clicked I want the reverse, and so on (toggle). I didn't see any code window for the controls. How can I code this? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle command buttons
OK, I replaced the forms buttons with ones from the control toolbox
and was able to code them. Thanks for your help. "GEB" wrote: From the Forms toolbar. "Bob Phillips" wrote: Where did you get the controls from the Forms toolbar or the control toolbox. -- HTH Bob Phillips "GEB" wrote in message ... I have an "Analysis" and a "Clear" button. At first I only want the "Analysis" button to be active and the "Clear" button disabled. After the "Analysis" button is clicked I want the reverse, and so on (toggle). I didn't see any code window for the controls. How can I code this? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
have toggle buttons but everytime print preview buttons move | Excel Discussion (Misc queries) | |||
Colouring Stuff, Toggle Buttons | Excel Programming | |||
Toggle Buttons | Excel Programming | |||
multiple toggle buttons | Excel Programming | |||
How can I use the Spin or Toggle buttons to change cell values | Excel Programming |