Hello,
I'm trying to create mutually exclusive check boxes and after some searching, have found a macro that allows me to do so. I've attached a spreadsheet that has the functioning macro in it, however there is 1 small problem. When I select 'Yes' in the attached sheet, it deselects the 'CheckBox1' option. Once I've selected either Yes, No or Unsure, I can go back and select 'CheckBox1' again and this time it will save both options.
What I want to be able to do is select either 'CheckBox1' or/and 'Checkbox2' (so these 2 options are not mutually exclusive). Then I want to also be able to select either 'Yes', 'No' or 'Unsure' without it unselecting the previous selections (i.e. these 3 options are mutually exclusive of eachother, and are exclusive of the first 2 options).
Can anyone help with what I'm sure is a real simple fix to the code I'm using?
Thanks very much
Gareth
*Edit - server won't let me attach the excel file, so I've attached a screen dump of my example, and code is below:
Private Sub Yes_Change()
With Me.Yes
If .Value Then ClearGroup .GroupName, .Name
End With
End Sub
Private Sub No_Change()
With Me.No
If .Value Then ClearGroup .GroupName, .Name
End With
End Sub
Private Sub Unsure_Change()
With Me.Unsure
If .Value Then ClearGroup .GroupName, .Name
End With
End Sub
Private Sub ClearGroup(sGroup As String, sName As String)
Dim ole As OLEObject
For Each ole In Me.OLEObjects
If TypeName(ole.Object) = "CheckBox" Then
If ole.Object.GroupName = sGroup And ole.Name <> sName Then
ole.Object.Value = False
End If
End If
Next ole
End Sub
Bookmarks