+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    03-18-2010
    Location
    IRELAND
    MS-Off Ver
    Excel 2003
    Posts
    1

    VBA and Dropdown box

    Hi there,

    I an try to get the value from a drop down box and place in it a cell.
    Does anyone know the code to do this .
    Please I am new to this and any help would be great.

    Thanks

  2. #2
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: VBA and Dropdown box

    What kind of "drop down" box are you using?

    Data validation - drop down?
    Forms Combo box?
    Combo box from the Controls Tool Box?

    The answer depends on the type of "drop down".
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: VBA and Dropdown box

    The exact code would depend on the name of your combobox and which cell you want to add the value to. Assuming the combobox is name JamCombo and you want it in cell A1, the code would be:

    Code:
    Cells(1,"A").Value = JamCombo.Value
    It depends on if the combobox is on the active worksheet, another worksheet, or a userform.
    If you gave more details or posted a sample worksheet it would be easier to provide you the info you are looking for.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  4. #4
    Forum Contributor thompsy121's Avatar
    Join Date
    09-25-2008
    Location
    Newcastle upon Tyne - UK
    MS-Off Ver
    Office 97 (work), Office 2003 (home)
    Posts
    116

    Re: VBA and Dropdown box

    Or to save time with re-naming or matching the names of combo boxes and avoiding debug errors...as Palmetto suggested...you can use data validation.

    To do this
    • Click the cell where you want the drop down box to be
    • Click Data, Validation
    • In the "Allow" drop-down box, select "List"
    • In the source box Type your options e.g A,B,C,D,E,Etc - make sure to seperate with a comma.
    • Click Ok

    Then finally where you want the cell to automatically link to it (this will display whatever option you have selected from the drop-down, click in that cell and type = and then click the cell where you drop-down (data validation box) is.

    Ex.

    Data Validation (drop-down box) is A1

    You want the cell match to be D1.....in D1 type =A1...this will then automatically change as to whatever has been selected in cell A1.

    Please see attached example.

    HTH
    Attached Files Attached Files
    Last edited by thompsy121; 03-19-2010 at 04:17 PM.

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.2.0