+ Reply to Thread
Results 1 to 2 of 2

How to check and uncheck a column of checkboxes with 1 checkbox?

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    1

    Lightbulb How to check and uncheck a column of checkboxes with 1 checkbox?

    Hi all,

    Is there a code to check and uncheck all checkboxes in a column A but not column B with 1 checkbox?

    I'm using form control checkboxes. I have only managed to find VBA coding to check all and uncheck all checkboxes in the active sheet with 2 different checkboxes.

    Sub CheckCheckBoxes()

    Dim Shp

    For Each Shp In ActiveSheet.Shapes
    X = Shp.Type
    If X = msoFormControl Then
    If Shp.FormControlType = xlCheckBox Then
    Shp.ControlFormat.Value = True
    End If
    End If
    Next Shp

    End Sub
    Sub ClearCheckBoxes()

    Dim Shp

    For Each Shp In ActiveSheet.Shapes
    X = Shp.Type
    If X = msoFormControl Then
    If Shp.FormControlType = xlCheckBox Then
    Shp.ControlFormat.Value = False
    End If
    End If
    Next Shp

    End Sub

    Thanks in advance!

  2. #2
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    198

    Re: How to check and uncheck a column of checkboxes with 1 checkbox?

    See if this macro does the job for you. It uses a function that
    identifies whether the check box is in column A or B, and then
    changes all the check box values in that column to the value
    of the controlling check box.

    As each check box name ends with a number, you adapt my code
    to your check boxes in column A using these numbers. To do this,
    edit the function and fill in your own numbers, where I have just 4 numbers
    (for the 4 check boxes in column A) in this example. Include a number for
    the column A controlling check box. The code assumes that any
    check box not identified as being in column A is in column B.

    If you decide to try this in your application, assign the first macro
    ColA_ChBoxes to the controlling check box in column A, and
    the second macro, ColB_CkBoxes, to the column B controlling
    check box.

    The example workbook is attached.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by xLJer; 10-11-2012 at 12:10 PM. Reason: Changed Sheet1 reference to ActiveSheet

+ 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