L
Luis
Hello.
I'm trying to create a vba routine to delete items from a listbox.
This is a multiselect listbox and what is happening is that i select several
items and the code only removes the first item. When the first item is
deleted, all of the other selected items became unselected.
I post the code i'm using bellow.
Can anyone give me a hint on this issue?
Thanks,
Luis
Private Sub RemoveItem_btn_Click()
If Listbox_1.ListIndex = -1 Then Exit Sub
For i = Listbox_1.ListCount - 1 To 0 Step -1
If Listbox_1.Selected(i) Then
Listbox_1.RemoveItem (i)
End If
Next i
End Sub
I'm trying to create a vba routine to delete items from a listbox.
This is a multiselect listbox and what is happening is that i select several
items and the code only removes the first item. When the first item is
deleted, all of the other selected items became unselected.
I post the code i'm using bellow.
Can anyone give me a hint on this issue?
Thanks,
Luis
Private Sub RemoveItem_btn_Click()
If Listbox_1.ListIndex = -1 Then Exit Sub
For i = Listbox_1.ListCount - 1 To 0 Step -1
If Listbox_1.Selected(i) Then
Listbox_1.RemoveItem (i)
End If
Next i
End Sub