drm51
04-30-2013, 05:28 AM
Hi,
I am referring back to a post “Solved: Uncheck Checkboxes if one is checked”, but have additional questions for this post. I am not familiar as how to reopen a “Solved” post, so I will post a new one. I am very limited in my knowledge of VBA.
The code showed in the above post and the one I listed below again, works great for checkboxes 1-5 alone, but I have many sets of checkboxes with 2 to 5 checkboxes in them that I would like to be independent of each other. If you check a checkbox within a set, the other checkboxes in that set will be unchecked, but it would not affect the other sets of checkboxes. I need for it to have only one checkbox in a set to be checked at a time.
I have listed the code presented former post as below:
Private Sub CheckBox1_Change()
SetCheckBoxes 1
End Sub
Private Sub CheckBox2_Change()
SetCheckBoxes 2
End Sub
Private Sub CheckBox3_Change()
SetCheckBoxes 3
End Sub
Private Sub CheckBox4_Change()
SetCheckBoxes 4
End Sub
Private Sub CheckBox5_Change()
SetCheckBoxes 5
End Sub
Private Function SetCheckBoxes(CBIndex As Long)
Dim x As Long
If Me.OLEObjects("CheckBox" & CBIndex).Object.Value Then
For x = 1 To 5
If x <> CBIndex Then
Me.OLEObjects("CheckBox" & x).Object.Value = False
End If
Next x
End If
End Function
Like I stated, this code works great for just ONE set “group” of checkboxes. How do I change this code to work independently for each set of checkboxes for multiple sets of checkboxes each having 2 to 5 checkboxes in them? There would be between 50 to 100 sets of checkboxes having 2-5 checkboxes in each, and up to 8 to 10 sheets.
Thank you very much for any help you can provide.
drm51
I am referring back to a post “Solved: Uncheck Checkboxes if one is checked”, but have additional questions for this post. I am not familiar as how to reopen a “Solved” post, so I will post a new one. I am very limited in my knowledge of VBA.
The code showed in the above post and the one I listed below again, works great for checkboxes 1-5 alone, but I have many sets of checkboxes with 2 to 5 checkboxes in them that I would like to be independent of each other. If you check a checkbox within a set, the other checkboxes in that set will be unchecked, but it would not affect the other sets of checkboxes. I need for it to have only one checkbox in a set to be checked at a time.
I have listed the code presented former post as below:
Private Sub CheckBox1_Change()
SetCheckBoxes 1
End Sub
Private Sub CheckBox2_Change()
SetCheckBoxes 2
End Sub
Private Sub CheckBox3_Change()
SetCheckBoxes 3
End Sub
Private Sub CheckBox4_Change()
SetCheckBoxes 4
End Sub
Private Sub CheckBox5_Change()
SetCheckBoxes 5
End Sub
Private Function SetCheckBoxes(CBIndex As Long)
Dim x As Long
If Me.OLEObjects("CheckBox" & CBIndex).Object.Value Then
For x = 1 To 5
If x <> CBIndex Then
Me.OLEObjects("CheckBox" & x).Object.Value = False
End If
Next x
End If
End Function
Like I stated, this code works great for just ONE set “group” of checkboxes. How do I change this code to work independently for each set of checkboxes for multiple sets of checkboxes each having 2 to 5 checkboxes in them? There would be between 50 to 100 sets of checkboxes having 2-5 checkboxes in each, and up to 8 to 10 sheets.
Thank you very much for any help you can provide.
drm51