I have a worksheet (Sheet10) with a table (“Shipping”).
When the UserForm opens, I get the data in a UserForm listbox.
I can edit items that are already in the table, I can also delete items that are already in the table.
I cannot seem to write new items from the UserForm to the Table in a new row.
I have tried multiple ways to accomplish this and always fail. The below code is the latest attempt but fails.
Thanks in advance for any and all assistance!
When the UserForm opens, I get the data in a UserForm listbox.
I can edit items that are already in the table, I can also delete items that are already in the table.
I cannot seem to write new items from the UserForm to the Table in a new row.
I have tried multiple ways to accomplish this and always fail. The below code is the latest attempt but fails.
Thanks in advance for any and all assistance!
VBA Code:
Error Message: Object doesnt support this property or method
Error Line: 10 (.Cells(LastRow, 1)…..)
VBA Code:
Private Sub ShippingFormToSheet()
Dim LastRow As Long
Dim rng As Range
Set rng = Sheet10.ListObjects("Shipping").Range
LastRow = rng.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
With Sheet10.ListObjects("Shipping") '.Range
''''''Write the data
.Cells(LastRow, 1).Value = textboxShippingOffice.Value 'Billing Office
.Cells(LastRow, 2).Value = textboxShippingCompany.Value 'Company
.Cells(LastRow, 3).Value = textboxShippingAddress.Value 'Address
.Cells(LastRow, 4).Value = textboxShippingCity.Value 'City
.Cells(LastRow, 5).Value = comboShippingState.Value 'State
.Cells(LastRow, 6).Value = textboxShippingZip.Value 'Zip
End With
End Sub