User Form, Combo Box, Moving Entries to spreadsheet


New Member
May 18, 2011

Could someone please assist an amateur in the transfer of data entered on a user form so that it appears on a spreadsheet.

I have created a user form with 4 text boxes labelled as: "Job Number"; "Customer Name"; "Suburb" and "State/Country. The next two entries are combo boxes labelled: "Engineer Name (cboengineer)" and "Engineer Code (cboFSR)".

I have created a worksheet named "LookupLists" with the data for the two combo boxes and I also have a "cmdadd" and a "cmdexit" button on the user form for transfering the entries on the form back to a worksheet named "formdata" and then to close the form. By the way, am I able to combine these two functions in to one button whereby the data is traansferred and the form closed at the same time?

The entries made on the user form from the textboxes transfer to the worksheet. However the entries from the combo boxes do not. Obviously this is because they haven't been told where to go. Could someone please advise how I add this function.

Please find below code for the user form:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("formdata")

iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

If Trim(Me.txtjobnumber.Value) = "" Then
MsgBox "Please enter Customer Details"
Exit Sub
End If

ws.Cells(iRow, 1).Value = Me.txtjobnumber.Value
ws.Cells(iRow, 2).Value = Me.txtcustomername.Value
ws.Cells(iRow, 3).Value = Me.txtsuburb.Value
ws.Cells(iRow, 4).Value = Me.txtstate.Value

Me.txtjobnumber.Value = ""
Me.txtcustomername.Value = ""
Me.txtsuburb.Value = ""
Me.txtstate.Value = ""

End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim cEng As Range
Dim cFSR As Range
Dim ws As Worksheet
Set ws = Worksheets("LookupLists")

For Each cEng In ws.Range("EngList")
With Me.cboengineer
.AddItem cEng.Value
End With
Next cEng

For Each cFSR In ws.Range("FSRList")
With Me.cboFSR
.AddItem cFSR.Value
End With
Next cFSR


End Sub

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...