+ Reply to Thread
Results 1 to 5 of 5

Mutually exclusive check boxes

  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:
    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by gazzz_tha1; 03-28-2012 at 09:16 PM. Reason: Adding attachment

  2. #2
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: Mutually exclusive check boxes

    This can be done but it is NOT considered good practice to do. This functionality is designed into radio button controls.

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

    Re: Mutually exclusive check boxes

    Thanks Dennis7849 - but that doesn't really help my situation..

  4. #4
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: Mutually exclusive check boxes

    If you use Radio buttons, you do not have to write extra code to get the same functionality.

    But if you must use checkboxes, then you will have to do this;

    In each checkbox_Change event, you must check the value to be checked(True). If it is True(Checked) then you must uncheck all other checkboxes. This is horribly inefficient to it this way.

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

    Re: Mutually exclusive check boxes

    Hi Dennis,

    I understand the difference between radio buttons and check boxes, and I understand what their intended uses are. I'm not interested in using radio buttons for this application. I'm not sure if you looked at my original code, but I've managed to get check boxes mutually exclusive, albeit with a slight problem.

    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).
    In easy terms - think of it as:
    Q1 - Please tell me about yourself?
    - Male.
    - Under 30 years old.

    Q2 - Do you like chicken?
    - Yes.
    - No.
    - Unsure.

    Currently, answering Q1 is fine, but the moment you answer Q2 it erases the responses from Q1. If you answer Q2 first, then answer Q1 - it works fine and we have a mutually exclusive response selection for Q2, and an answer for Q1...

+ Reply to Thread

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