VBA Form

ldarley

Board Regular
Joined
Apr 10, 2012
Messages
106
Office Version
  1. 2019
  2. 2016
Hi I'm having some difficulty with an excel vba form I've created. I load the form from a the first set of code which I've placed in a module, nice and simple works. Then I enter the data and on clicking a command button I need to load the data from the form into a table.

So if I test the form from running my Sub CommandButtonCreate_Click() from within the userform vba it all works fine. However if I Run the DataForm Macro to load the form from within the spreadsheet and then click on the command button only the non userform data ( newrow.Range(1) & (2)) loads into the table, nothing form the Combo or text boxes. I'm sure there's something obvious I've gotten wrong here, pointers gratefully recieved!


VBA Code:
Sub DataForm()
Dim frm As UserForm1

Set frm = New UserForm1
    frm.Show

End Sub

VBA Code:
Sub CommandButtonCreate_Click()

Dim ws As Worksheet
Dim tbl As ListObject
Dim newrow As ListRow
Dim x As Long

Set ws = Data
Set tbl = ws.ListObjects("Dossier")
Set newrow = tbl.ListRows.Add
 
 x = tbl.Range.Rows.Count

    'update list
    newrow.Range(1).Value = "Textbox " & x - 1
    newrow.Range(2).Value = x - 1
    newrow.Range(3).Value = UserForm1.ComboBoxTeam.Value
    newrow.Range(4).Value = UserForm1.TextBoxDescription.Text
    newrow.Range(5).Value = UserForm1.ComboBoxType.Text
    newrow.Range(6).Value = UserForm1.ComboBoxRAG.Text

End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Just point to the already created userform, so in my example , my userform is named Mysuserform, change the name to yours and see if that works
VBA Code:
Sub Dataform()
    Myuserform.Show
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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