Fordraiders
asked on
remove specific items from a listbox
excel 2010 vba
I have a listbox on a userform
I'm filling the listbox via getrows method
What I need:
Specifically in column 13 in the listbox.
I may have values such as : "WD" "DV" "WV" "WG"
I want to press a command button and remove all the rows that have these value in
column13
If no items exist in the listbox meeting this criteria then msbgox "No Items To Delete"
I have to keep pressing the command button until all are deleted doing this ?
Dim i As Long
With Me.ListBox1
For i = 0 To .ListCount - 1
If .List(i, 13) = "DG" Then
.RemoveItem i
Exit For ' if i remove this line then my listcount gets messed up and i get errors
End If
Next
End With
Thanks
fordraiders
I have a listbox on a userform
I'm filling the listbox via getrows method
What I need:
Specifically in column 13 in the listbox.
I may have values such as : "WD" "DV" "WV" "WG"
I want to press a command button and remove all the rows that have these value in
column13
If no items exist in the listbox meeting this criteria then msbgox "No Items To Delete"
I have to keep pressing the command button until all are deleted doing this ?
Dim i As Long
With Me.ListBox1
For i = 0 To .ListCount - 1
If .List(i, 13) = "DG" Then
.RemoveItem i
Exit For ' if i remove this line then my listcount gets messed up and i get errors
End If
Next
End With
Thanks
fordraiders
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I assume it's actually column 14 then? ;)
ASKER
perefect Thanks very much
You're welcome and I'm glad I was able to help.
Marty - MVP 2009 to 2012
Marty - MVP 2009 to 2012