I have a user form with Delete button that deletes the selected item inside my listbox whenever it is clicked. And every time there is a deleted item there, the deleted item should also be removed in my Worksheet range. How can i delete a selected row in the listbox?
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Private Sub CmdDelete_Click()
Dim i As Integer
For i = 1 To Range("A1000000").End(xlUp).Row
If Cells(i, 1) = Listbox1.List(Listbox1.ListIndex) Then
Rows(i).Select
Selection.Delete
End If
Next i
End Sub</code>
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Private Sub CmdDelete_Click()
Dim i As Integer
For i = 1 To Range("A1000000").End(xlUp).Row
If Cells(i, 1) = Listbox1.List(Listbox1.ListIndex) Then
Rows(i).Select
Selection.Delete
End If
Next i
End Sub</code>