Avatar of Fordraiders
Fordraiders
Flag for United States of America 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
Microsoft Excel

Avatar of undefined
Last Comment
Martin Liss

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Martin Liss

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Rory Archibald

I assume it's actually column 14 then? ;)
Fordraiders

ASKER
perefect  Thanks very much
Martin Liss

You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2012
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck