I have a Userform listBox that displays data from the worksheet. I want to delete the worksheet row based on the selection on listBox.
The code deletes the row above, not the selected row according to listbox.
Private Sub CommandButton3_Click()
Dim i As Integer
For i = 0 To Range("A65356").End(xlUp).Row - 1
If lstDisplay.Selected(i) Then
Rows(i).Select
Selection.Delete
End If
Next i
End Sub
i + 1
....? Also, better not to delete in a loop. UseUnion
to create a range to delete, and delete it after the loop. Also useLong
, notInteger
. – BigBen