+ Reply to Thread
Results 1 to 13 of 13

Only allow up to 4 checkboxes to be True in Userform

  1. #1
    Registered User
    Join Date
    02-02-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    47

    Only allow up to 4 checkboxes to be True in Userform

    Hello,

    Can someone help me to realize this?

    I made a Userform with 10 check boxes and I would want this Userform to only allow
    up to 4 check boxes to be selected or true? selecting more must give an error message.

    thx
    Last edited by Bluewhistler; 04-30-2010 at 03:46 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Only allow up to 4 checkboxes to be True in Userform

    Hi Bluewhistler
    Maybe some thing like
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    02-02-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Only allow up to 4 checkboxes to be True in Userform

    O, I'm sorry for the late reply I was waiting for en email notification,
    I wasn't even subscribed to my own thread. lol

    I'll let you know if your code does the trick.

    Ok, I didn't manage to get this working. and when I read your code I understand you got to put in every checkbox in it.

    I am gonna have about 10 and there will be more added in time.

    can we not make a check when i click on the next button of the Userform containing the checkboxes? as you can see this is just im thinking logicaly I can't write vba but am starting to understand better.

    Please Login or Register  to view this content.
    or the other way around

    Please Login or Register  to view this content.
    Last edited by Bluewhistler; 05-19-2010 at 10:25 AM.

  4. #4
    Registered User
    Join Date
    02-02-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Only allow up to 4 checkboxes to be True in Userform

    Can someone have a look at this, plz?
    I still haven't found the answer?

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Only allow up to 4 checkboxes to be True in Userform

    Click GO ADVANCED and use the paperclip icon to post up a desensitized copy of your workbook.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Registered User
    Join Date
    02-02-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Only allow up to 4 checkboxes to be True in Userform

    Ok,

    There's nothing in the workbook except for the userform.
    Just a error message needed whe there are more than 4 checked true.

    I also made another thread because nobody was answering this question, but its not the same question thoug.

    thx
    Attached Files Attached Files

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Only allow up to 4 checkboxes to be True in Userform

    Here's how I would approach this. It will disable all other checkboxes once you select 4...couldn't be more obvious to the user than that.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JBeaucaire; 05-19-2010 at 02:09 PM.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    This change to the initialize routine would make it work for as many checkboxes as you have created, no need to edit the macro after this.

    This also gets your EXIT button working:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 05-19-2010 at 02:09 PM.

  9. #9
    Registered User
    Join Date
    02-02-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Only allow up to 4 checkboxes to be True in Userform

    Your right, your approch in post7 is far better then what I was looking for.

    now
    I'm going to need a cmdbutton on this userform to go to another "userform2", but I would like this button to stay locked untill 2 checkboxes are true.

    It all comes down to be able to select only 2, 3, or 4 checkboxes.

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Only allow up to 4 checkboxes to be True in Userform

    Like so:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    02-02-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Only allow up to 4 checkboxes to be True in Userform

    Thats exacly what I needed!
    It makes sense when I read and try to understand the vba code. But to make those myself is another story.
    I' am going to try to learn this in night school if I can find it somewhere closely.

    Can I ask for another code in this thread? its related to this one so…

    Here it is:
    This Userform1 now allows 2, 3 or 4 checkboxes right. Which is perfect
    The next step is to have Userform2 show up when ok is clicked
    Userform 2 contains only 4 Labels. That I would like to have the Captions to be the selected checkboxes captions in Userform1.
    theres an attachment where i tried to make this work? the first label add works but i can't get the other 3 to be added on the userform.
    the captions i haven't got any clue?
    Attached Files Attached Files
    Last edited by Bluewhistler; 05-26-2010 at 05:08 AM.

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Only allow up to 4 checkboxes to be True in Userform

    Check checkboxes independent of their names:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    02-02-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: Only allow up to 4 checkboxes to be True in Userform

    I'm already lost?
    what does this do and how do i use this.
    Quote Originally Posted by snb View Post
    Check checkboxes independent of their names:

    Please Login or Register  to view this content.

+ 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