Hi All,
I am trying to do two things with a userform.
#1 : add a new row to bottom of existing table, the table is called "Table1". (my current code does this part just fine)
#2 , populate the first cell in that new row with a textbox.text that is in a userform called UserForm1, the text box is called textbox50.
With my code i am using below, i get the following error: Run-time error '424': Object required
Would anyone be able to help me out to get this to work? It has something to do with the "textbox50.text" because i can get this to populate other data, for example selection.value = "Test" would work just fine.
Here is code:
I am trying to do two things with a userform.
#1 : add a new row to bottom of existing table, the table is called "Table1". (my current code does this part just fine)
#2 , populate the first cell in that new row with a textbox.text that is in a userform called UserForm1, the text box is called textbox50.
With my code i am using below, i get the following error: Run-time error '424': Object required
Would anyone be able to help me out to get this to work? It has something to do with the "textbox50.text" because i can get this to populate other data, for example selection.value = "Test" would work just fine.
Here is code:
Code:
Sub addrow()
Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects("Table1")
Dim newrow As ListRow
Set newrow = tbl.ListRows.Add
With newrow
.Range(, 1).Select
Selection.Value = TextBox50.Text
End With
TextBox50.Text = ""
End Sub