Good morning everyone,
I am having a problem getting my code to work. I am trying to find a record in a userform, edit it and then save it back to the spreadsheet. I have successfully used a combobox to locate the individuals name and show their details, and a hidden textbox to store the ID number. The code that I have sourced and customised works for changes in the first field only. Any changes I make to any other fields does not show on the spreadsheet. Any comments on the code would be appreciated.
Private Sub cmdUpdate_Click()
Dim Rw As Range
For Each Rw In Range(cboName.RowSource)
If cboName.Column(1) = txtID.Text Then
cboName.Column(2) = cboContactType.Value
cboName.Column(3) = cboSalutation.Value
cboName.Column(4) = txtFirstname.Value
cboName.Column(5) = txtSurname.Value
cboName.Column(6) = txtJobTitle.Value
cboName.Column(7) = txtCompany.Value
cboName.Column(8) = txtStreetAddress.Value
cboName.Column(9) = txtSuburb.Value
cboName.Column(10) = cboState.Value
cboName.Column(11) = txtPostcode.Value
cboName.Column(12) = txtWorkPhone.Value
cboName.Column(13) = txtMobile.Value
cboName.Column(14) = txtEmail.Value
cboName.Column(15) = txtStartDate.Value
cboName.Column(16) = txtHourlyRate.Value
cboName.Column(17) = txtComments.Value
End If
Next Rw
MsgBox ("Details updated")
ActiveWorkbook.Save
End Sub
Cheers,
Nunans
Bookmarks