+ Reply to Thread
Results 1 to 8 of 8

UserForm listbox/combobox

  1. #1
    Registered User
    Join Date
    08-18-2010
    Location
    Leeds, England
    MS-Off Ver
    Excel 2003
    Posts
    28

    UserForm listbox/combobox

    Hey all,

    I am trying to construct a UserForm to have a listbox that is dependent on the contents of a combobox. I have found a few posts which explain the process that always leave me with code to debug!

    I have attached an example of what I’m trying to achieve. Worksheet 1 has the lists and worksheet 2 has a button to open the form. The form has a button to close it and the combo/list boxes on it.

    The bits which I haven’t done which always get me are naming the list ranges and adding the code to buttons… …any help with this one is greatly appreciated!!

    Many thanks,

    Adele
    Attached Files Attached Files
    Last edited by adeleex; 08-25-2011 at 03:54 AM.

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

    Re: UserForm listbox/combobox

    Please Login or Register  to view this content.



  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: UserForm listbox/combobox

    Hi adeleex, try the attached workbook and let me know if it meets your requirements.
    Attached Files Attached Files
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  4. #4
    Registered User
    Join Date
    08-18-2010
    Location
    Leeds, England
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: UserForm listbox/combobox

    Mordred, not quite i was trying to get it so when the user clicks Adele or Sam from the combobox the list box underneath would show their films

    For Adele in te combobox you would get a coice of Ponyo / Spirited Away / Princess Mononoke in the list box

    When Sam is selected in the dropbox you get in the list box Moon / The Road / Crazy Heart...

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: UserForm listbox/combobox

    Try this next upload.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-18-2010
    Location
    Leeds, England
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: UserForm listbox/combobox

    Mordred, really appreciate your help on this at the risk of being fussy there a few problems with this.

    On my actual form there is already a submit button to send the data to a database so I’d like it so when the user selects either of the combobox menu items it populates one list or the other without the need to hit a submit button…

    Many thanks

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

    Re: UserForm listbox/combobox

    You only need 2 lines of code:

    Please Login or Register  to view this content.
    Alternative method:

    Please Login or Register  to view this content.
    Cfr. the attachment

    @Mordred

    Never use 'additem' to populate (i.e. >1 ) a listbox/combobox
    Attached Files Attached Files
    Last edited by snb; 08-24-2011 at 02:51 PM.

  8. #8
    Registered User
    Join Date
    08-18-2010
    Location
    Leeds, England
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: UserForm listbox/combobox

    snb, this works a treat, even I can understand the coding & added funky colour too haha... thankyou!! xx
    Last edited by adeleex; 08-25-2011 at 03:56 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