+ Reply to Thread
Results 1 to 11 of 11

Userform: ComboBox Automatically Populating

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Userform: ComboBox Automatically Populating

    Hey Everyone,

    First off, thank you all so much for your help. I mere 5 weeks ago I didn't know what VB was. Now I'm creating user forms, and big Macros! You have all been so helpful.

    Down to Business:

    I've created what I'm calling an Acronym Database (its an excel workbook) . In this work book I have created a user form to enter new Acronyms. When prompted the form displays.

    On the form I have a comboBox labelled "Context of Use". When I click the dropdown arrow a list of preloaded terms appear, if the term you want to use doesn't appear in the drop down, you may type it directly into the combo box.

    What I'm interested in doing is; if I create a new term in this "Context of Use" combo box called "Y" then add my new acronym to the "Database". When I open the form again to add another Acronym, I want this new term, "Y", that I previously created in the context box to appear on the drop down menu.

    Does anyone have any ideas of how I could do this?

    I have thought about creating a hidden worksheet in which I could save these "Context of Use" categories. Then use this hidden worksheet to populate the form. Although I'm not sure if this is the best method, or how to even implement it.

    Thanks in advance. I have attached the workbook for your review.

    Attached Files Attached Files
    Last edited by ashleys.nl; 10-14-2011 at 08:48 AM. Reason: Forgot to attach workbook

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

    Re: Userform: ComboBox Automatically Populating

    We need to see what you are doing - where the combobox is loading from in particular.

    Attach an example workbook
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Userform: ComboBox Automatically Populating

    Sorry about that Roy,

    I thought I had a workbook attached.

    Thanks for you interest

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform: ComboBox Automatically Populating

    I'd be tempted to hold the scope in a separate sheet and load the contents into the combo box when loading, this makes it easy to add additional scopes:

    so if your list was in column A in Sheet2
    Please Login or Register  to view this content.
    New scopes could then be added as below:
    Please Login or Register  to view this content.
    Last edited by Kyle123; 10-14-2011 at 08:31 AM.

  5. #5
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Userform: ComboBox Automatically Populating

    Beautiful! That's exactly what I was thinking I just didn't know how to implement it! thank you soo much!

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform: ComboBox Automatically Populating

    You might also want to sort them before populating your combobox

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Userform: ComboBox Automatically Populating

    That's what I was just attemping. However, when I try your code I get an error

    "Run-Time Error '1004'

    The Sort reference is not valid. Make Sure that it's within the data you want to sort, and the first sort by box isn't the same or blank" Specifically the code I used was

    Please Login or Register  to view this content.

    Attached Files Attached Files

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform: ComboBox Automatically Populating

    try changing it to this:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Userform: ComboBox Automatically Populating

    That Works Great!

    Although, now I've noticed another issue, even if I use a term that's already on sheet 3, it adds a duplicate. Any idea how I could combat this?

    PS thank you soo much for all your help !

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform: ComboBox Automatically Populating

    By changing your code for adding and sorting to this:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Talking Re: Userform: ComboBox Automatically Populating

    THANK YOU SOOOOOO MUCH!!!!!!! It works GREAT

+ 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