Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Togglebuttons in a Userform.

Nevermind, adding

If ToggleButton2.Value = False Then ToggleButton1.Value = True

seems to sort it.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change 'Caption' on ToggleButtons with VBA Jay Excel Programming 0 March 28th 07 02:57 AM
Change 'Caption' on ToggleButtons with VBA Greg Wilson Excel Programming 0 March 28th 07 02:47 AM
Moving togglebuttons Fugazy Excel Discussion (Misc queries) 0 August 15th 06 02:54 PM
change the value of togglebuttons Nelson Excel Programming 1 November 10th 04 04:17 AM
ToggleButtons are strange Ken McLennan[_3_] Excel Programming 7 October 11th 04 09:40 AM


All times are GMT +1. The time now is 12:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"