+ Reply to Thread
Results 1 to 10 of 10

Master & Slave Check Boxes

Hybrid View

  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.
    Private Sub CheckBox1_Click()
    
      If CheckBox1.Value = True Then CheckTheseBoxes "CheckBox2", "CheckBox3", "CheckBox4", "CheckBox5"
      
    End Sub
    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.
    Function CheckTheseBoxes(ParamArray Checkbox_Names() As Variant)
    
      Dim ChkBox As Object
      Dim I As Integer
      
        For I = 0 To UBound(Checkbox_Names)
          Set ChkBox = ActiveSheet.OLEObjects(Checkbox_Names(I)).Object
          ChkBox.Value = True
        Next I
        
    End Function
    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

+ 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