Consulting

Results 1 to 5 of 5

Thread: Solved: Insert text selected from a combobox into cell

  1. #1

    Solved: Insert text selected from a combobox into cell

    Hi all,

    I have a userform (Userform1) with 3 comboboxes (Combobox1, Combobox2, Combobox3) and an "Add" button (Commandbutton1). My question is, how can I get the selected text from Combobox1 (for example), click the "Add" button and get the text pasted into cell A9?

    Any help will be much appreciated and if i've left any vital info out please let me know

    Thanks in advance

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    like this?

    [VBA]
    Private Sub CommandButton1_Click()
    Worksheets("Sheet1").Range("A9").Value = ComboBox1.Value
    End Sub

    [/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    Thanks very much, i didn't realise it was that simple. I was assuming it would be so much more complicated. How wrong I was!

  4. #4
    Just a quick additional question if you don't mind.

    I'm having the combobox as a multi option box so is there any manipulation of the above code that will paste the 2nd selection into A10 (and so on)?

  5. #5
    I've found this and it does a similar thing but I can't seem to edit it to start looking for the next empty cell at A9 in column A. I'm also having trouble putting in the answer above from Mancubus correctly. Can anyone help with this please?

    [vba]Private Sub EnterButton_Click()
    Dim NextRow As Long
    ' Make sure Sheet1 is active
    Sheets("Sheet1").Activate
    ' Determine the next empty row
    NextRow = Application.WorksheetFunction. _
    CountA(Range("A:A")) + 1

    ' Alternate method of getting next empty row
    'NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1

    End Sub[/vba]

Posting Permissions

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