troubleshooting Question

remove specific items from a listbox

Avatar of Fordraiders
FordraidersFlag for United States of America asked on
Microsoft Excel
4 Comments1 Solution301 ViewsLast Modified:
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

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
End With

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros