+ Reply to Thread
Results 1 to 16 of 16

add list user form, list box and get input

  1. #1
    Registered User
    Join Date
    12-10-2009
    Location
    plano
    MS-Off Ver
    Excel 2007
    Posts
    11

    add list user form, list box and get input

    Hello,

    I desperately need help in excel vba. I wrote a macro which creates desired output based on one default variables. But I want to change it to take user selected assumptions and perform the macro for each user selected variables.

    I am confused with user forms and controls and what to use.

    Can anyone give the code to how to add a list box to a userform and then add items to the listbox, and run macro based on thegiven input in the list box??

    Thanks.
    Last edited by rajaneeshjandhyam; 12-17-2009 at 12:22 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: add list user form, list box and get input

    Start here
    http://www.contextures.com/xlUserForm01.html

  3. #3
    Registered User
    Join Date
    12-10-2009
    Location
    plano
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: add list user form, list box and get input

    thanks davesexcel; i reviwed the code in the link. it does not tell how to add list box to the user form and add items to the list. can you give link for that?

    thanks.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: add list user form, list box and get input

    Why do you need code to add the controls?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    12-10-2009
    Location
    plano
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: add list user form, list box and get input

    I want teh code about adding items to list box and then using the user selection in the lixt box as input for another macro.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: add list user form, list box and get input

    So you have added the controls manually?

    Attach an example workbook

  7. #7
    Registered User
    Join Date
    12-10-2009
    Location
    plano
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: add list user form, list box and get input

    here it is attached.
    Attached Files Attached Files

  8. #8
    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: add list user form, list box and get input

    Hi rajaneeshjandhyam
    The attached workbook contains a demo on how to do what your asking. It's from http://www.lacher.com
    and is a free download.
    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.

  9. #9
    Registered User
    Join Date
    12-10-2009
    Location
    plano
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: add list user form, list box and get input

    Hi jaslake,

    your file shows a list typed in a sheet that is linked to the list box. Can I somehow add the items to the list by not having them in any of the sheets (probably through code)? and to how to get the input from the user into the code?

  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: add list user form, list box and get input

    Hi rajaneeshjandhyam
    You could fill the list box with an initialize event with code; there's many examples of this on the web. Just do a search on "initialize listbox vba". As far as this
    how to get the input from the user into the code
    here is an example that I wrote just yesterday
    Please Login or Register  to view this content.
    If you need further explanation, let me know.
    John

  11. #11
    Registered User
    Join Date
    12-10-2009
    Location
    plano
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: add list user form, list box and get input

    jaslake,

    Thanks for your guidance. Now I have a little understanding how forms and listboxes work. i was able to add a list box and call it with a button click from a sheet. it shows on the form i created and the values I initialized in the list box. I changed the property to select multiple items. how can i read multiple items selected into a macro that is located in a module?

    Thanks for you help so far and in advance. thanks to other guys too who have been helping.
    Last edited by rajaneeshjandhyam; 12-17-2009 at 05:49 PM.

  12. #12
    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: add list user form, list box and get input

    Hi rajaneeshjandhyam
    When one uses a single select listbox, you just refer to the listbox value as I previously posted. I've never created a multi-select list box so would need to research that on the web. I did a quick look by searching "multi-select listbox vba" and there's a bunch of stuff there. There are plenty of people on this site that can help you with that issue; I'd need to learn it before I could help.
    If you get stuck and can't find answers, let me know. I'm into learning.
    John

  13. #13
    Registered User
    Join Date
    12-10-2009
    Location
    plano
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: add list user form, list box and get input

    Hi jaslake

    i found the code on the web and im using it. but have another issues, trying to figure out those.

    thnks.

  14. #14
    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: add list user form, list box and get input

    Hi rajaneeshjandhyam
    I'd be interested in learning about multi-select list-boxes myself. Do you have a link to that code? Are there other issues I can help you with?
    John

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

    Re: add list user form, list box and get input

    jaslake,

    this is the code i used;

    Please Login or Register  to view this content.
    link: http://www.ozgrid.com/VBA/multi-select-listbox.htm

    im having issues with sheet names. i am trying to get sheetnames from a work based on a condition. here is the code:

    Please Login or Register  to view this content.
    I guess I cant subtract strings. any suggestions?
    Last edited by rajaneeshjandhyam; 12-18-2009 at 10:56 AM. Reason: Code tags required when showing VBA code

  16. #16
    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: add list user form, list box and get input

    Hi rajaneeshjandhyam
    Thanks for the code. Regarding this
    I guess I cant subtract strings. any suggestions?
    You can subtract strings if you convert them to integers with "VAL". I have no idea if this will work with what you're trying to do.
    Keep me posted on your success. John

+ 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