Results 1 to 5 of 5

Mutually exclusive check boxes

Threaded View

  1. #1
    Registered User
    Join Date
    11-17-2010
    Location
    Canberra, Australia
    MS-Off Ver
    Excel 2010
    Posts
    19

    Mutually exclusive check boxes

    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
    Attached Images Attached Images
    Last edited by gazzz_tha1; 03-28-2012 at 09:16 PM. Reason: Adding attachment

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1