Toggle buttons

F

FloMM2

To All,
I have a spreadsheet that I have added togglebuttons to (5).
Can someone help me with the proper program to:
If togglebutton1 is selected, it will unselect the other toggle buttons.
Thanks for the help.
 
J

John Bundy

Just double click them and turn the others off in code, there are prettier
ways but they are harder to understand:

Private Sub ToggleButton1_Click()
If ToggleButton1 = True Then
ToggleButton2 = False
ToggleButton3 = False
ToggleButton4 = False
ToggleButton5 = False
End If

End Sub

Private Sub ToggleButton2_Click()
If ToggleButton2 = True Then
ToggleButton1 = False
ToggleButton3 = False
ToggleButton4 = False
ToggleButton5 = False
End If
End Sub

Private Sub ToggleButton3_Click()
If ToggleButton3 = True Then
ToggleButton1 = False
ToggleButton2 = False
ToggleButton4 = False
ToggleButton5 = False
End If
End Sub

Private Sub ToggleButton4_Click()
If ToggleButton4 = True Then
ToggleButton1 = False
ToggleButton2 = False
ToggleButton3 = False
ToggleButton5 = False
End If
End Sub

Private Sub ToggleButton5_Click()
If ToggleButton5 = True Then
ToggleButton1 = False
ToggleButton2 = False
ToggleButton3 = False
ToggleButton4 = False
End If
End Sub
 
R

Ray

I'm not 100% sure this is correct ... I'm sure someone else 'smarter'
will correct me ... :)

The nature of toggle buttons is that if you have multiple on your
sheet, selecting one automatically de-selects the others -- if not,
you may not be using 'toggle buttons'. They should be round, with a
little black circle in them when selected.

As for how to code them, you can use this basic template (by Tom
Ogilvy):

Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
MsgBox "depressed" ' or your code here'
Else
MsgBox "Not depressed"' ' or your code here'
'etc,etc,etc....

End If
End Sub
 
F

FloMM2

John,
Thank you soooooo much.
I have been sending a lot of time tweaking this to try and get it.
You hit it out of the park, thank you.
Dennis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top