Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default togglebutton to act like optionbutton

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default togglebutton to act like optionbutton

Had another look at this and if my assumption is right that you only want
your code to run when the option button is true then I think that this is a
simpler option. It changes all other options to false and you can put your
code in after the code that changes the other option buttons:-

Private Sub ToggleButton1_Click()
If ToggleButton1 = True Then
ToggleButton2.Value = False
ToggleButton3.Value = False
ToggleButton4.Value = False
ToggleButton5.Value = False
'Any other code here

End If

End Sub

Private Sub ToggleButton2_Click()
If ToggleButton2 = True Then
ToggleButton1.Value = False
ToggleButton3.Value = False
ToggleButton4.Value = False
ToggleButton5.Value = False
'Any other code here

End If

End Sub

Private Sub ToggleButton3_Click()
If ToggleButton3 = True Then
ToggleButton1.Value = False
ToggleButton2.Value = False
ToggleButton4.Value = False
ToggleButton5.Value = False
'Any other code here
End If

End Sub

Private Sub ToggleButton4_Click()
If ToggleButton4 = True Then
ToggleButton1.Value = False
ToggleButton2.Value = False
ToggleButton3.Value = False
ToggleButton5.Value = False
'Any other code here

End If

End Sub

Private Sub ToggleButton5_Click()
If ToggleButton5 = True Then
ToggleButton1.Value = False
ToggleButton2.Value = False
ToggleButton3.Value = False
ToggleButton4.Value = False
'Any other code here


End If
End Sub
--
Regards,

OssieMac


"OssieMac" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default togglebutton to act like optionbutton

I think that will work.
Thanks

"OssieMac" wrote:

Had another look at this and if my assumption is right that you only want
your code to run when the option button is true then I think that this is a
simpler option. It changes all other options to false and you can put your
code in after the code that changes the other option buttons:-

Private Sub ToggleButton1_Click()
If ToggleButton1 = True Then
ToggleButton2.Value = False
ToggleButton3.Value = False
ToggleButton4.Value = False
ToggleButton5.Value = False
'Any other code here

End If

End Sub

Private Sub ToggleButton2_Click()
If ToggleButton2 = True Then
ToggleButton1.Value = False
ToggleButton3.Value = False
ToggleButton4.Value = False
ToggleButton5.Value = False
'Any other code here

End If

End Sub

Private Sub ToggleButton3_Click()
If ToggleButton3 = True Then
ToggleButton1.Value = False
ToggleButton2.Value = False
ToggleButton4.Value = False
ToggleButton5.Value = False
'Any other code here
End If

End Sub

Private Sub ToggleButton4_Click()
If ToggleButton4 = True Then
ToggleButton1.Value = False
ToggleButton2.Value = False
ToggleButton3.Value = False
ToggleButton5.Value = False
'Any other code here

End If

End Sub

Private Sub ToggleButton5_Click()
If ToggleButton5 = True Then
ToggleButton1.Value = False
ToggleButton2.Value = False
ToggleButton3.Value = False
ToggleButton4.Value = False
'Any other code here


End If
End Sub
--
Regards,

OssieMac


"OssieMac" wrote:

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

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
Togglebutton ranswrt Excel Programming 4 July 23rd 08 11:29 PM
Togglebutton ranswrt Excel Programming 0 July 23rd 08 10:27 PM
Setting ToggleButton Value fazstp[_4_] Excel Programming 6 February 1st 06 04:31 AM
need help with togglebutton Gary Keramidas[_2_] Excel Programming 7 July 9th 05 04:15 PM
2 macros in a Togglebutton? Jorge[_2_] Excel Programming 1 August 11th 03 01:57 AM


All times are GMT +1. The time now is 06:52 AM.

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"