+ Reply to Thread
Results 1 to 7 of 7

Select All Checkbox

  1. #1
    Registered User
    Join Date
    09-18-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    35

    Select All Checkbox

    hi all,

    I'm using Excel 2007.

    I have 20 check/tick boxes on my worksheet (CheckBox1-20), each of the 20 tickboxs has its own linked cell A1-A20 - I wish to have another checkbox (checkbox21) that, when ticked will tick all of them.

    Also, if unticked it will untick the 20. I'd like this to be a kind of "onclick" command - so that if I wanted to tick 5 of the 20 on their own, the "master" tick box won't interfere with this. If a command button is easier to code than this is just as good.

    I've been looking online on on here for the last 2 hours with no joy, not even getting close. Any help would be greatly appreciated.

    I am using Form Controls rather than ActiveX controls.

    Kind regards

    ChainsawDR
    Last edited by ChainsawDR; 10-28-2009 at 07:25 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: Select All Checkbox

    Something like this, where the routine CheckAll is assigned to the master checkbox.
    You may need to change the control names.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    09-18-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Select All Checkbox

    it worked a treat, thank you so very much Andy.

  4. #4
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Select All Checkbox

    or -- try
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: Select All Checkbox

    Jack, you have to be careful when checking the value of the checkbox.
    Value is not a true boolean. The checkbox can have 4 different values controlling it's 3 states.

    0 or -4146 when unchecked
    1 when checked
    2 when mixed state


    ps: Good to see/read you back in the world of xl

  6. #6
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Select All Checkbox

    Cheers Andy, very rusty thou been a good year or more out

    Ermm code worked in testing, cheers for the pointer.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: Select All Checkbox

    To illustrate the problem,
    Uncheck all the checkboxes and with the check box 1 unchecked run your code.

    The unchecked state returns -4146 which the code treats as TRUE and therefore sets all the other checkboxes to checked.

    Edit: just uncovered the constants

    Please Login or Register  to view this content.
    Last edited by Andy Pope; 10-28-2009 at 08:55 AM.

+ 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