Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,


    What I'm trying to do is utilize a ComboBox in a userform to populate a certain cell.

    Here is the code I have for the ComboBox:


    Private Sub ComboBox1_Enter()

    ComboBox1.List() = Range("R1:R49").Value

    End Sub


    As you can see, I'm populating the data in the combobox from data in column R. I can select what I desire, so I'm good so far. What I need to happen is for whatever selection is made to be populated in another cell (for example purposes, let's use A1). After it's populated, I need the userform to go away. I can figure that out...I just haven't got that far yet.

    Thanks for any advice. It is much appreciated.

    I'm using Excel 2007

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You can set the RowSource property of the combo box to R1:R49 in the Visual Basic Editor instead of in code, and you can set the ControlSource property to the address of the cell to which you want to link the value of the combo box, e.g. A1 - again, no code necessary.

  3. #3
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='777316' date='28-May-2009 10:53']You can set the RowSource property of the combo box to R1:R49 in the Visual Basic Editor instead of in code, and you can set the ControlSource property to the address of the cell to which you want to link the value of the combo box, e.g. A1 - again, no code necessary.[/quote]

    Hey, thanks for the pointer on that. I got it to work, but it only populates the cell when I click the X to close it.

    Now that I'm not using code, I'm not sure how to make the userform go away.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If selecting an item in the combo box made the userform go away, the user wouldn't be able to correct mistakes. So I'd place a command button cmdClose next to the combo box with the following code:

    Code:
    Private Sub cmdClose_Click()
      Unload Me
    End Sub

  5. #5
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='777323' date='28-May-2009 11:25']If selecting an item in the combo box made the userform go away, the user wouldn't be able to correct mistakes. So I'd place a command button cmdClose next to the combo box with the following code:

    Code:
    Private Sub cmdClose_Click()
      Unload Me
    End Sub
    [/quote]


    Very nice.

    That did it. Thanks for the tips and the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •