Send data from a combobox on a userform to table in spreadsheet

Gem866

New Member
Joined
Feb 11, 2015
Messages
16
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
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
it is only the data from the textboxes that is adding into the new table the combo box data is not populating the table.
That's weird, but try using combobox.Text instead of combobox.Value:
.Cells(LastRow, 2).Value = Me.CBWE.Text
 
Upvote 0
What do you have in the BoundColumn property of the combobox?

You should have 1.

1686875771399.png




--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
 
Upvote 0
Solution
What do you have in the BoundColumn property of the combobox?

You should have 1.

View attachment 93707



--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
Thank you that has resolved the issue. Now working perfectly. For some reason I had 2 in the bound column but the tables only contained 1 column.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top