Second click on toggle button?

Ronix

Board Regular
Joined
Aug 18, 2014
Messages
54
Hi Guys..., I have this code below. If I push first button the value 1 is saved to the cell E3, if I push second button the value 1 is saved to the cell E6 and value from cell E3 is deleted and first button is in default state. This everything is fine. But I need to modify this script below as follow: If first or second button is pushed and value is saved to the given cell I want to forbid the second clicking option when the button could be switched to the default. The button will be switched to default state upon other button is pushed. Almost it is reached in this script but I dont know how to prohibit the second click option on the already pushed button. Thanks in advance!
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
Range("E3") = 1
ToggleButton1.BackColor = RGB(0, 255, 0)
ToggleButton2.Value = False

Else: ToggleButton1.BackColor = RGB(255, 0, 0)
Range("E3") = ""
End If
End Sub
Private Sub ToggleButton2_Click()
If ToggleButton2.Value = True Then
Range("E6") = 1
ToggleButton2.BackColor = RGB(0, 255, 0)
ToggleButton1.Value = False

Else: ToggleButton2.BackColor = RGB(255, 0, 0)
Range("E6") = ""
End If
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hmm Andrew, If I change Enabled state to false the button is totally deactivated. I cannot click on it. But I need to do first click on it and prohibit second click on it.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

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