Arie Bos
Board Regular
- Joined
- Mar 25, 2016
- Messages
- 224
- Office Version
- 365
- Platform
- Windows
I have a table with 42 columns and 10 rows with customer date in each row. I made a form in which the user can fill in all the textboxes and then save as a new row to this table. Works all fine.
No, a have a similar form in which and existing customer can be 'lifted' out of the table to make changes later, using a combobox. This also works fine.
Where I am stuck, is how to write all textboxes, some with updated content, back to the same row as where they came from.
below lists my latest attempt:
(CustomerData = the full table
SelectedClient = the range with company names used in the combobox to search the company to be edited))
Where do I go wrong?
No, a have a similar form in which and existing customer can be 'lifted' out of the table to make changes later, using a combobox. This also works fine.
Where I am stuck, is how to write all textboxes, some with updated content, back to the same row as where they came from.
below lists my latest attempt:
(CustomerData = the full table
SelectedClient = the range with company names used in the combobox to search the company to be edited))
Where do I go wrong?
VBA Code:
Private Sub btnSaveEditsCompany_Click()
Dim CustomerData As Range
Set CustomerData = Range("A6").CurrentRegion
Dim clientRow As Long
clientRow = Application.Match(CStr(selectedClient), CustomerData.Columns(5), 0)
' Wait for user to edit data and click the "Save" button
' Save edited data back into the table
CustomerData.Cells(clientRow, 5).Value = txtClientCompanyName.Value
CustomerData.Cells(clientRow, 6).Value = txtClientPhone.Value
CustomerData.Cells(clientRow, 7).Value = txtClientWebsite.Value
CustomerData.Cells(clientRow, 8).Value = txtSalesAgent.Value
CustomerData.Cells(clientRow, 9).Value = txtClientAddress.Value
CustomerData.Cells(clientRow, 10).Value = txtClientCity.Value
CustomerData.Cells(clientRow, 11).Value = txtClientZip.Value
MsgBox "Client data has been updated.", vbInformation, "Success"
End Sub