Hi all.
I have a userform which imports data from a table. At the moment when a textbox is changed it Saves A:LLthe textbox data back to respective cells. What I need is that the save will only overwrite changed data back into the table and not overwrite data which hasnt changed.
here is my code so far
I have a userform which imports data from a table. At the moment when a textbox is changed it Saves A:LLthe textbox data back to respective cells. What I need is that the save will only overwrite changed data back into the table and not overwrite data which hasnt changed.
here is my code so far
VBA Code:
Private Sub cmdAddData_Click()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet2")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Me.ComboBox1.Value = ws.Cells(i, "A") Then
ws.Cells(i, "B") = txtFirstname.Value
ws.Cells(i, "C") = TxtSurname.Value
ws.Cells(i, "D") = TxtDOB.Value
ws.Cells(i, "E") = Gender.Value
ws.Cells(i, "F") = Membership.Value
ws.Cells(i, "H") = MemberSince.Value
ws.Cells(i, "G") = FEESnowpaid.Value
ws.Cells(i, "I") = PaidDate.Value
End If
Next i
End Sub
Last edited by a moderator: