Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 42

Thread: Userform Checkboxes - Select All/Unselect

  1. #11
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,820
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    You will need to explain more about exactly what you want to happen.
    And you should only use my code.
    Tell me the name of the Checkbox you want the code in.
    You do not need to enter my code in more the one checkbox.

    And no code is needed in any of the other Check Boxes.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  2. #12
    MrExcel MVP mikerickson's Avatar
    Join Date
    Jan 2007
    Location
    Davis CA
    Posts
    22,597
    Post Thanks / Like
    Mentioned
    20 Post(s)
    Tagged
    15 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    I agree that a full explaination of what you are trying to achieve is needed.
    The first post where you resurected this 8 year old thread isn't clear if you want a "Un/Check All" checkbox to apply to only some check boxes or all checkboxes (as My Answer Is's code handles).
    If there are only some checkboxes to be handled, are they all in the same Group?
    Are there any in the Group not to be controlled by the master?
    Are the Master and the Sub checkboxes in the same Frame/MultiPage?
    Do you want it back informative, i.e. as you un/check the sub checkboxes, do you want the Master checkbox to be checked/unchecked/null depending on the mix of the group?
    Last edited by mikerickson; Oct 7th, 2019 at 10:53 AM.

  3. #13
    Board Regular
    Join Date
    Aug 2019
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    I have 38 CheckBoxes. All checkboxes 1-38 are named CheckBox1, CheckBox2, CheckBox3, etc. Checkboxes 1-37 serve a function of hiding a specific column. Checkbox38 is the select/deselect all. Originally, I started with regular checkboxes directly on my sheets and everything was perfect except for an intolerable glitch where when I sorted my data, it would cause my checkboxes to move such that the checkbox would be in the right spot but the place to click it would shift about an inch. So I created my checkboxes in a userform and copied my code over.

    The purpose of the userform is to allow users to easily hide columns that they do not want to see. Since there are so many checkboxes, I want to add a select/ deselect all checkbox.

  4. #14
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,820
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    And so did my code not work for you?
    Put my code in CheckBox38
    And the code would be:


    Code:
    Private Sub CheckBox38_Click() 'Modified 10/7/2019 11:26:25 AM EDT For Each Control In Me.Controls If TypeName(Control) = "CheckBox" Then Control.Value = CheckBox38.Value Next End Sub
    When you click on CheckBox38 the code runs.
    Last edited by My Aswer Is This; Oct 7th, 2019 at 11:27 AM.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  5. #15
    Board Regular
    Join Date
    Aug 2019
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    Its working now. I had to delete the checkboxes that I had and put new ones in because I think something was wrong with the names of the checkboxes.
    Thank you!

  6. #16
    Board Regular
    Join Date
    Aug 2019
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    Nevermind.
    So it was working, then I added control source references so that when I open and close the Userform, the checkmarks save. Now when I click the Select all button, Checkbox1 is the only one that changes

  7. #17
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,820
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    What is a select all Button?
    You said:

    Now when I click the Select all button, Checkbox1 is the only one that changes

    You said earlier you wanted the script to run when you selected TextBox 38

    See we can only help you when you provide specific details.

    And you earlier said:
    The purpose of the userform is to allow users to easily hide columns that they do not want to see. Since there are so many checkboxes, I want to add a select/ deselect all checkbox.

    I do not know why you would need a UserForm with 38 checkboxes to hide columns

    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  8. #18
    Board Regular
    Join Date
    Aug 2019
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    I apologize for being vague. By button, I meant CheckBox38. When I select and deselect (check/uncheck) CheckBox38, the only checkbox of the other 37 to be affected is CheckBox1.

    For why I need a userform, I will not be the primary user of this spreadsheet. I am trying to make it as easy as possible for other users. Users are going to be constantly hiding columns they don't need to see. Can you think of a better way to hide columns in a user friendly way?

    Do you know why adding a ControlSource to the checkboxboxes would cause th Select/Deselect all functionally to fail?

  9. #19
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,820
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    I would think having a user double click on say Range(A1) to hide Column 1 would be a easy way.
    But then unhiding would not work this way.


    You said earlier you had 38 Checkboxes and you want to click Checkbox38 which then would select all the other 37 checkboxes.

    But in your last post you said:
    the only checkbox of the other 37 to be affected is CheckBox1.


    So tell me what you wanted to happen.

    Are you wanting a user to easily hide and unhide columns? Or just hide them.

    And then you want to do something easy to unhide all columns. Is that what you want.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  10. #20
    Board Regular
    Join Date
    Aug 2019
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Checkboxes - Select All/Unselect

    What I would like:

    A userform with 37 checkboxes that work as a toggle switch to hide and unhide columns. When the checkbox 1-37 is TRUE, then 'show column', when checkbox 1-37 is FALSE, then 'hide column. My current code is written to do that.
    Then another checkbox (CheckBox38) that toggles all the 37 checkboxes to be checked or unchecked. When CheckBox38 is TRUE, then 'Show all columns', when CheckBox38 is FALSE, then 'Hide all columns'. OR When CheckBox38 is TRUE, then 'CheckBoxes 1-37 are TRUE', when CheckBox38 is FALSE, then 'CheckBoxes 1-37 are FALSE'

    When the userform is closed and reopened, I should see the same checkbox configuration as the last time it was open.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •