karolina1406
Board Regular
- Joined
- Apr 18, 2016
- Messages
- 110
- Office Version
- 365
- Platform
- Windows
hi All,
I have a UserForm in each tab on my spreadsheet. It's the same for each sheet. I use below code to send the info from the Userform to the master table in a different sheet. A Table that i want to populate is called ReserveSpaceRequests and ints in a ReserveSpaceReq sheet. Belo code works is the UserForm is placed in the ReserveSpaceReq sheet but it doesn't work from any other sheet... I am getting an error message at rng.Select. Any ideas why?
I have a UserForm in each tab on my spreadsheet. It's the same for each sheet. I use below code to send the info from the Userform to the master table in a different sheet. A Table that i want to populate is called ReserveSpaceRequests and ints in a ReserveSpaceReq sheet. Belo code works is the UserForm is placed in the ReserveSpaceReq sheet but it doesn't work from any other sheet... I am getting an error message at rng.Select. Any ideas why?
VBA Code:
Dim oNewRow As ListRow
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("ReserveSpaceReq").Range("ReserveSpaceRequests")
rng.Select
Set oNewRow = Selection.ListObject.ListRows.Add(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 3).Value = Me.TextBox1.Value
oNewRow.Range.Cells(1, 4).Value = Me.TextBox2.Value
oNewRow.Range.Cells(1, 5).Value = Me.ComboBox1.Value
oNewRow.Range.Cells(1, 2).Value = Me.TextBox3.Value
oNewRow.Range.Cells(1, 8).Value = Me.TextBox4.Value
oNewRow.Range.Cells(1, 10).Value = Me.TextBox7.Value
oNewRow.Range.Cells(1, 11).Value = Me.TextBox9.Value
oNewRow.Range.Cells(1, 12).Value = Me.TextBox13.Value
End With