Hello everyone, hope you're having a great day.
I made a userform with a listbox that reads from a database in excel. I added some buttons like add, delete and i added a update button so you can select data from the listbox and update using textboxes.
The problem is that when i use the button it only updates the first row and i dont know what i am missing in my code so it updates the row i selected instead of just updating the first row.
any help would be great.
Here is the code i have:
Ps: I have 98 columns of data but i only put the first 2 just to show what i have.
I made a userform with a listbox that reads from a database in excel. I added some buttons like add, delete and i added a update button so you can select data from the listbox and update using textboxes.
The problem is that when i use the button it only updates the first row and i dont know what i am missing in my code so it updates the row i selected instead of just updating the first row.
any help would be great.
Here is the code i have:
Ps: I have 98 columns of data but i only put the first 2 just to show what i have.
VBA Code:
Dim currentrow As Long
Private Sub UserForm_Initialize()
currentrow = 6
txtdepot = Cells(currentrow, 2)
txtref_clients = Cells(currentrow, 3)
Private Sub cmdUpdate_Click()
Dim answer
answer = MsgBox("Confirm if you want to update the record?", vbYesNo + vbQuestion, "Update Record")
If answer = vbYes Then
Cells(currentrow, 2) = txtdepot.Text
Cells(currentrow, 3) = txtref_clients.Text
End If
End Sub