I have a UserForm [frmAddNewCustomer] and I am trying to get the data entered into a Table [Customers] on Sheet [Customer List] in the next row in the Table when the user clicks Add
The code is:
However, when I run the UserForm I don't get any error but nothing is placed in the table
Any help gratefully received
The code is:
Code:
Private Sub cmbAdd_Click()
Dim lastRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customer List")
With ws.ListObjects("Customers")
.ListColumns("Company Name").Range(lastRow) = txtCust.Value
.ListColumns("Address Line 1").Range(lastRow) = txtAddress1.Value
.ListColumns("Address Line 2").Range(lastRow) = txtAddress2.Value
.ListColumns("Address Line 3").Range(lastRow) = txtAddress3.Value
.ListColumns("Town").Range(lastRow) = txtTown.Value
.ListColumns("County").Range(lastRow) = txtCounty.Value
.ListColumns("Post Code").Range(lastRow) = txtPostCode.Value
.ListColumns("Name").Range(lastRow) = txtCustomerName.Value
.ListColumns("Phone").Range(lastRow) = txtPhone.Value
.ListColumns("email address").Range(lastRow) = txtemail.Value
Unload Me
End With
End Sub
However, when I run the UserForm I don't get any error but nothing is placed in the table
Any help gratefully received