Hi,
I have a form control button on Sheet 9 that opens up a userform. I want the data entered into the userform to be entered into a table (table3) on sheet 8 of a workbook. When the control button is on sheet 8 the code works perfect, but when the button is on page 9 it does not.
The code I am using is below:
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("Sheet8").Range("Table3")
rng.Select
Set oNewRow = Selection.ListObject.ListRows.Add(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 1).Value = Me.txtDate
oNewRow.Range.Cells(1, 2).Value = Me.txtName
oNewRow.Range.Cells(1, 3).Value = Me.txtGender
oNewRow.Range.Cells(1, 4).Value = Me.txtDOB
Any help would be appreciated.
Thanks.
I have a form control button on Sheet 9 that opens up a userform. I want the data entered into the userform to be entered into a table (table3) on sheet 8 of a workbook. When the control button is on sheet 8 the code works perfect, but when the button is on page 9 it does not.
The code I am using is below:
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("Sheet8").Range("Table3")
rng.Select
Set oNewRow = Selection.ListObject.ListRows.Add(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 1).Value = Me.txtDate
oNewRow.Range.Cells(1, 2).Value = Me.txtName
oNewRow.Range.Cells(1, 3).Value = Me.txtGender
oNewRow.Range.Cells(1, 4).Value = Me.txtDOB
Any help would be appreciated.
Thanks.