+ Reply to Thread
Results 1 to 10 of 10

Master & Slave Check Boxes

  1. #1
    Registered User
    Join Date
    05-24-2008
    Posts
    12

    Master & Slave Check Boxes

    Hi all,

    What I need is five check boxes. One will be a master. If it is checked, the other four will be checked as a result. If the master is not checked, the four slaves can be checked independently and not affect the others.
    I am using the Control Toolbox, if that matters.

    Thanks you in advance your your help.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello flmoose,

    Have you considered using Option Buttons? Their default behavior is for one and only one to be set at a time.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-24-2008
    Posts
    12
    Option buttons won't work, because the user needs to be able to select one or more options at a time. The master would just make it easier to select all.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello flmoose,

    Sorry, I misread your post. Where are these check boxes to be located - on a VBA UserForm or Excel worksheet?

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    05-24-2008
    Posts
    12
    They will be located on an Excel worksheet.
    Basically, if the user wants to select all the options, they can select the master box, otherwise they can check the boxes individually to get the desired comination.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello flmosse,

    Here is the code for the Master check box.
    Please Login or Register  to view this content.
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Save the macro in your Workbook using CTRL+S


    Here is the macro to control the other check boxes. Change the names in the code to match your check box names.
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    05-24-2008
    Posts
    12
    That works great! Thanks!

    Is there any way to program it so all the slave boxes will uncheck when I uncheck the master? I want an easy way for the user to clear the form too.

    I thought I might be able to get away with just adding a line that states if checkbox1 is false then donotchecktheseboxes, but I guess it's not that simple. LOL
    Last edited by flmoose; 06-03-2008 at 10:01 AM.

  8. #8
    Registered User
    Join Date
    05-24-2008
    Posts
    12
    I thought I might be able to get away with just adding a line that states if checkbox1 is false then donotchecktheseboxes, but when that didn't work I realized that your 'checktheseboxes' is a function being run by the macro, so to add that to the macro, I need to add to the function as well.
    I'm guessing the integer is what tells the function to check the boxes, is that correct? If so, what integer would I set to uncheck the boxes?

    Please Login or Register  to view this content.
    As you can tell, I'm not a 'expert' by any means in Excel of Visual Basic.
    Your help is greatly appreciated.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello flmoose,

    A second macro is need to clear the check boxes, A call to this macro then needs to be added to the master check box event code. Here is the second macro to clear the check boxes
    Please Login or Register  to view this content.
    Master Checkbox Event Code
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  10. #10
    Registered User
    Join Date
    05-24-2008
    Posts
    12
    That's it exactly! Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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