ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   toggling checkboxes (https://www.excelbanter.com/excel-programming/421014-toggling-checkboxes.html)

tony

toggling checkboxes
 
I want to add several checkboxes to the worksheet and to have them working
similar to option box, so that only one can be selected in any particulart
time. I have created several procedures acting on CheckBox_click event but I
can not figure on how to set the values for other checkboxes. Using

CheckBox2.Value = False

or

CheckBox2.Value = 0

does not work, I am getting error messages related to missing objects. How
my code should look like ? Thanks for help.

Regards,


FSt1

toggling checkboxes
 
hi
here is one way to do it. you may have to work your other code in/around it.
the trick is that if one checkbox is true(checked) the others are set to
false with all checkboxes looking at all the other checkboxes.
Private Sub CheckBox1_Click()
If CheckBox1 = True Then
CheckBox2 = False
CheckBox3 = False
End If
End Sub

Private Sub CheckBox2_Click()
If CheckBox2 = True Then
CheckBox1 = False
CheckBox3 = False
End If
End Sub

Private Sub CheckBox3_Click()
If CheckBox3 = True Then
CheckBox1 = False
CheckBox2 = False
End If
End Sub

regards
FSt1

"Tony" wrote:

I want to add several checkboxes to the worksheet and to have them working
similar to option box, so that only one can be selected in any particulart
time. I have created several procedures acting on CheckBox_click event but I
can not figure on how to set the values for other checkboxes. Using

CheckBox2.Value = False

or

CheckBox2.Value = 0

does not work, I am getting error messages related to missing objects. How
my code should look like ? Thanks for help.

Regards,



All times are GMT +1. The time now is 10:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com