Hi,
I have a spreadsheet with 100 to 150 checkboxes on it. I have them separated into 3 to 4 checkboxes going down one column with several empty cells between them. I want each group of 3 to 4 checkboxes to only show one checkbox as true at a time. If a checkbox without a check in it is checked, the other checkbox with the check in it become unchecked. I found the code below SetCheckBoxes, and it works great for one set of checkboxes, say Checkboxes 1-3, but when I try using this same function again to duplicate the function for, say for Checkboxes 4-7, I get a “Compile error: Ambiguous name detected: SetCheckBoxes”. How can I make each group of checkboxes work independently from each other? I am very limited to my knowledge of VBA.
Thank You,
drm51
Here is the code I found:
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 Function SetCheckBoxes(CBIndex As Long)
Dim x As Long
If Me.OLEObjects("CheckBox" & CBIndex).Object.Value Then
For x = 1 To 3
If x <> CBIndex Then
Me.OLEObjects("CheckBox" & x).Object.Value = False
End If
Next x
End If
End Function
Bookmarks