View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default togglebutton to act like optionbutton

Unfortunately it does not appear that you can suppress events from running
with the toggle buttons using Application.EnableEvents. However, I
successfully got the following to work. I set a linked cell for each of the
Toggle buttons so that I could observe their behaviour and it appears to work
OK.

Dim bolToggle As Boolean

Private Sub ToggleButton1_Click()
MsgBox "ToggleButton1_Click ran" & ToggleButton1.Value
If ToggleButton1 = True Then
bolToggle = False
ToggleButton2.Value = False
ToggleButton3.Value = False
ToggleButton4.Value = False
ToggleButton5.Value = False
End If

bolToggle = True

End Sub

Private Sub ToggleButton2_Click()
If bolToggle = True Then
MsgBox "ToggleButton2_Click ran" & ToggleButton2.Value
End If
End Sub

Private Sub ToggleButton3_Click()
If bolToggle = True Then
MsgBox "ToggleButton3_Click ran" & ToggleButton3.Value
End If
End Sub

Private Sub ToggleButton4_Click()
If bolToggle = True Then
MsgBox "ToggleButton4_Click ran" & ToggleButton4.Value
End If
End Sub

Private Sub ToggleButton5_Click()
If bolToggle = True Then
MsgBox "ToggleButton5_Click ran" & ToggleButton5.Value
End If
End Sub

--
Regards,

OssieMac


"ranswrt" wrote:

I have a worksheet with 5 toggle buttons. I need to get them to act like
option buttons where when one is clicked the other values will be set to
false. I tried using the click event for each togglebutton to set the other
toggles values to false, but as each one is set to false, the click event for
that toggle runs. Any ideas how I can get this to work or is there a way to
make option buttons look like toggle buttons?
Thanks