+ Reply to Thread
Results 1 to 7 of 7

dropdown list/ComboBox

  1. #1
    Registered User
    Join Date
    11-15-2010
    Location
    Norway
    MS-Off Ver
    Office 11
    Posts
    17

    dropdown list/ComboBox

    Hello.

    I want to make a dropdown list in a UserForm.

    I have created the drop down list, but I do not know how to get data from the excel sheet in the list and how to find out which of the numbers in the list, the user has clicked.

  2. #2
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: dropdown list/ComboBox

    There are a couple of ways to fill your Combobox.

    First there is a property called "row source" that needs a range to point it to the data that you want to use in the Combobox. (Easiest)

    \1





    Second you can leave the row source blank and use the .AddItem method where you can fill the Combobox each time the UserForm is initiated. (always has the updated info)

    ....and there is another 3rd way that is escaping me at the moment, maybe one of the other forum members will chime in and jog my memory.


    EDIT:can you post an example workbook?, it helps someone like me who isn't all that versed in VBA to figure out what is going on with the problem that you describe.
    Last edited by jwright650; 01-26-2011 at 08:51 AM. Reason: added picture of Row Source in Properties Window
    Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
    John Wright

  3. #3
    Registered User
    Join Date
    11-15-2010
    Location
    Norway
    MS-Off Ver
    Office 11
    Posts
    17

    Re: dropdown list/ComboBox

    "]can you post an example workbook?, it helps someone like me who isn't all that versed in VBA to figure out what is going on with the problem that you describe"
    Attached Files Attached Files

  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: dropdown list/ComboBox

    Take a look at this
    Attached Files Attached Files
    Hope that helps.

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

    Free DataBaseForm example

  5. #5
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: dropdown list/ComboBox

    Here is yo0ur file with the row source filled in (A1:A5) - see properties window, scroll down to "row source"

    Also added some code to your command button to enter the number chosen into cell B1
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-15-2010
    Location
    Norway
    MS-Off Ver
    Office 11
    Posts
    17

    Re: dropdown list/ComboBox

    First, thanks for the great help!
    I have another question.
    Now I have changed a bit on the file RoyUK made, and I want the text to come in the dropdown list, but number to the right of the text is pasted into cell C1 (so if you choose "One"in the dropdown list, it should write "1 "C1
    Attached Files Attached Files

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

    Re: dropdown list/ComboBox

    Try this, I've amended the code to display two columns in the combobox & use the ComboBox's List property

    Or you can use the same settings as the first example
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by royUK; 01-26-2011 at 01:49 PM.

+ 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