PDA

View Full Version : Solved: Insert text selected from a combobox into cell



owen_1987
08-22-2011, 05:44 AM
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

mancubus
08-22-2011, 06:13 AM
like this?


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

owen_1987
08-22-2011, 06:20 AM
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!

owen_1987
08-22-2011, 07:53 AM
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)?

owen_1987
08-23-2011, 01:30 AM
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?

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