Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Togglebuttons in a Userform.
My userform has 2 togglebuttons. Both should clear checkboxes 1-4, and enable
these checkboxes if the togglebutton is "on", or disable if the togglebutton is "off". This is working great so far. and this is probably only a little thing, but when I click one of the buttons to "On", I want the other to revert to "Off". I had it on _change() instead of _click() but the problem was still the same. If one of the buttons is set to "on" and I click the other it will indeed reset the first to "off", but thats all it does. The frame and checkbox Disable and the button isn't clicked "on". I also tried moving the part about changing togglebutton1 to false to the top, but doesn't seem to help. It appears that the macro is triggering because you click on the box, but its not switching it on on the first click for some reason? Private Sub ToggleButton2_click() With Frame1 .Enabled = ToggleButton2.Value End With With CheckBox1 .Value = False .Enabled = ToggleButton2.Value End With With ToggleButton1 .Value = False End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Togglebuttons in a Userform.
Nevermind, adding
If ToggleButton2.Value = False Then ToggleButton1.Value = True seems to sort it. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Togglebuttons in a Userform.
here's some (UNTESTED) ideas:
Private Sub ToggleButton2_click() ToggleButton1.Value = False 'might need Me.ToggleButton1 'rest of code to do whatever End Sub and then, Private Sub ToggleButton1_click() ToggleButton2.Value = False 'might need Me.ToggleButton1 'rest of code to do whatever End Sub OR you could put an entirely different code set up in a general module, to the effect of: Private Sub ToggleButton2_click() 'either one 'put this in the userform code ToggleButton1.Value = False Call Change_other_toggle 'rest of code to do whatever End Sub sub Change_other_toggle 'put this in the other module if userform1.togglebutton1.value = true then userform1.togglebutton2.value = false userform1.checkbox1.enabled=false userform1.checkbox2.enabled=false 'etc end if if userform1.togglebutton2.value=true then userform1.togglebutton1.value=false 'enter other checkboxes to be disabled end sub hth susan On Apr 10, 8:30 am, PaulW wrote: My userform has 2 togglebuttons. Both should clear checkboxes 1-4, and enable these checkboxes if the togglebutton is "on", or disable if the togglebutton is "off". This is working great so far. and this is probably only a little thing, but when I click one of the buttons to "On", I want the other to revert to "Off". I had it on _change() instead of _click() but the problem was still the same. If one of the buttons is set to "on" and I click the other it will indeed reset the first to "off", but thats all it does. The frame and checkbox Disable and the button isn't clicked "on". I also tried moving the part about changing togglebutton1 to false to the top, but doesn't seem to help. It appears that the macro is triggering because you click on the box, but its not switching it on on the first click for some reason? Private Sub ToggleButton2_click() With Frame1 .Enabled = ToggleButton2.Value End With With CheckBox1 .Value = False .Enabled = ToggleButton2.Value End With With ToggleButton1 .Value = False End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change 'Caption' on ToggleButtons with VBA | Excel Programming | |||
Change 'Caption' on ToggleButtons with VBA | Excel Programming | |||
Moving togglebuttons | Excel Discussion (Misc queries) | |||
change the value of togglebuttons | Excel Programming | |||
ToggleButtons are strange | Excel Programming |