I am a novice with VBA.
I have created a userform in excel. The form contains a few combo boxes and a couple of text boxes.
The combo boxes on the form get their data from some tables that have been created in a spreadsheet. All good so far it seems.
The problem is that when the form is completed and submitted via a commandbutton it is only the data from the textboxes that is adding into the new table the combo box data is not populating the table. I need help to fix this.
The text boxes are Textbox1 & TxtQty and the Combo boxes are CBWE, CBCUST, CBPRODUCT, CBRETURN.
Please help as to why the combo box data is not populating on the table.
With thanks
Here is the VBA code currently
Private Sub CommandButton1_Click()
Dim LastRow As Long
With Worksheets("Data Input")
.ListObjects("Data_Input").ListRows.Add
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Cells(LastRow, 2).Value = Me.CBWE.Value
.Cells(LastRow, 1).Value = Me.TextBox1.Value
.Cells(LastRow, 4).Value = Me.CBCUST.Value
.Cells(LastRow, 5).Value = Me.CBPRODUCT.Value
.Cells(LastRow, 6).Value = Me.TxtQty.Value
.Cells(LastRow, 7).Value = Me.CBReturn.Value
End With
'Call Clearform
End Sub
I have created a userform in excel. The form contains a few combo boxes and a couple of text boxes.
The combo boxes on the form get their data from some tables that have been created in a spreadsheet. All good so far it seems.
The problem is that when the form is completed and submitted via a commandbutton it is only the data from the textboxes that is adding into the new table the combo box data is not populating the table. I need help to fix this.
The text boxes are Textbox1 & TxtQty and the Combo boxes are CBWE, CBCUST, CBPRODUCT, CBRETURN.
Please help as to why the combo box data is not populating on the table.
With thanks
Here is the VBA code currently
Private Sub CommandButton1_Click()
Dim LastRow As Long
With Worksheets("Data Input")
.ListObjects("Data_Input").ListRows.Add
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Cells(LastRow, 2).Value = Me.CBWE.Value
.Cells(LastRow, 1).Value = Me.TextBox1.Value
.Cells(LastRow, 4).Value = Me.CBCUST.Value
.Cells(LastRow, 5).Value = Me.CBPRODUCT.Value
.Cells(LastRow, 6).Value = Me.TxtQty.Value
.Cells(LastRow, 7).Value = Me.CBReturn.Value
End With
'Call Clearform
End Sub