+ Reply to Thread
Results 1 to 14 of 14

Populate checkboxes based on drop down menu

  1. #1
    Registered User
    Join Date
    10-15-2009
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Populate checkboxes based on drop down menu

    Hey!

    Ok, so I am making a form. At the top there is a dropbox with a list of applications. Based on which application the user picks, I want another section of the form to populate check boxes with the name of the projects that are associated with that application. Some applications have 2 projects, some applications have 7 projects.

    Anyone have any ideas? Thanks!
    Last edited by Broadway; 10-19-2009 at 01:23 PM.

  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

    Re: Populate checkboxes based on drop down menu

    Hello Broadway,

    Welcome top the Forum!

    If you post your workbook it will be easier and faster to get answers to your questions.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-15-2009
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Populate checkboxes based on drop down menu

    I would upload the workbook, but I don't have one. I haven't started building the form yet, because I need to know if this is possible. If it is not then I need to try and think of a different solution. If you would like to see a mock up I could do that. I know the theory of programming and can read VB but I don't have an intimate understanding of the language, so I don't know whether something like this is even possible.

  4. #4
    Registered User
    Join Date
    10-15-2009
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Populate checkboxes based on drop down menu

    I made a mock up of what the form will look like. There is no VB code yet, because I cannot find any way of doing this, but the mock up should let you visualize what I am trying to do.

    I want to select and instance from the instance drop down, and then have the projects that are associated with that instance populate the projects area with check boxes.

    Instance A has 7 projects associated with it
    Instance B has 5 projects associated with it
    Instance C has 2 projects associated with it

    I hope this is more clear. Thanks for your time!
    Attached Files Attached Files

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Populate checkboxes based on drop down menu

    You may want to use a UserForm for this exercise. The attached might get you started.
    Hope this helps. J
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  6. #6
    Registered User
    Join Date
    10-15-2009
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Populate checkboxes based on drop down menu

    The userform looks like a great idea! I spent some time looking at them and how they work and built a new one from scratch. I am almost finished with it, but I am not sure about one thing.

    The code for the button. Currently I have it clear the cells of the data page, and then set whatever is in the combo box as the instance. Now I just want it to do the same thing only with whatever is checked. I'm not sure how I should do this. I was trying to make and array and then save each checked value into it, and then reprint it to the data sheet, but I couldn't get it working. Does anyone have a better idea or some guidance?

    Thank you!
    Attached Files Attached Files

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Populate checkboxes based on drop down menu

    Looks like you made quite a bit of progress. Try this code for your Add Projects button
    Please Login or Register  to view this content.
    It worked for me on your post.
    Hope this helps. J

  8. #8
    Registered User
    Join Date
    10-15-2009
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Populate checkboxes based on drop down menu

    Worked PERFECTLY...you are awesome. Thanks so much for all the help!!

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Populate checkboxes based on drop down menu

    Hello Broadway,

    This workbook contains the check boxes. These will appear and disappear depending on the length of the displayed list. Another macro, a UDF, is included to allow you to check if the check box is checked or not. have a look and give me some feedback on the idea.
    Attached Files Attached Files

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Populate checkboxes based on drop down menu

    Glad it works for you. I had a college professor who used to tell me
    "It's not as important to know the answer as it is to know where to find the answer"
    The answer to your question was found at http://www.ozgrid.com/VBA/multi-select-listbox.htm.
    I noticed on your user form, you don't allow the user to close the form with the "X" in the upper right hand corner. I've used this technique in the past but I've always included a "Cancel" button. Don't want the user to get frustrated.
    Just a thought. J

  11. #11
    Registered User
    Join Date
    10-15-2009
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Populate checkboxes based on drop down menu

    jaslake - Yea I actually decided to do away with the code and let the user close the box with the X just because I found it annoying.

    Ross- This is exactly what I was looking for to begin with! I am going to spend some time looking at it and learning how it works.

    I have some scripting background in unix, but I just started looking into VB last week to do some projects at my job. You guys are definitely helping me out so much. Thanks to both of you for your time and help.

  12. #12
    Registered User
    Join Date
    10-15-2009
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Populate checkboxes based on drop down menu

    Hey Leith, I need to change the background color of the drop down box...but Im not sure where you are setting it?

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Populate checkboxes based on drop down menu

    Hello Broadway,

    To change the color of the ComboBox (from Controls ToolBox):
    1. open the Visual Basic Editor using ALT+F11
    2. Press the keys ALT+R then the letter m. This puts you in design mode. To see the property sheet you have to be in design mode.
    3. In the Project window, click on "Sheet1(Sheet1)"
    4. Display the Properties window by pressing F4
    5. Click the drop down in the Properties window and select ComboBox1
    6. Select BackColor
    7. Click the drop down button to the right and you will see the Color Pallette
    8. Select your color.

  14. #14
    Registered User
    Join Date
    02-28-2014
    Location
    philippines
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Populate checkboxes based on drop down menu


+ 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