Hello guys.
I'm making a form and i added a delete button to a database that i already had.
I created a list box inside the form so you can see the database while you're filling the form. The idea of my delete button is to be able to select a row in the listbox and be able to press delete and delete that row.
The problem i'm running into is that when i add data to the form and then go to the last entry i added and try to delete it, it deletes another row instead i cant i figure out what is wrong with my code.
If you guys could help would be awesome.
Here is the code i got for the delete button:
I'm making a form and i added a delete button to a database that i already had.
I created a list box inside the form so you can see the database while you're filling the form. The idea of my delete button is to be able to select a row in the listbox and be able to press delete and delete that row.
The problem i'm running into is that when i add data to the form and then go to the last entry i added and try to delete it, it deletes another row instead i cant i figure out what is wrong with my code.
If you guys could help would be awesome.
Here is the code i got for the delete button:
VBA Code:
Private Sub cmdDelete_Click()
Dim i As Integer
For i = 0 To Range("B65356").End(xlUp).Row - 1
If lstDisplay.Selected(i) Then
Rows(i + 1).Select
Selection.Delete
End If
Next i
End Sub