troubleshooting Question

removing items from listbox  with OR statement not working

Avatar of Fordraiders
FordraidersFlag for United States of America asked on
Microsoft Excel
13 Comments2 Solutions128 ViewsLast Modified:
userform
listbox
command button

I have a list of items in a listbox that i wan to filter.

With UserForm2.ListBox32
    For ri = .ListCount - 1 To 0 Step -1
    If .List(ri, 3) <> "DG" Or .List(ri, 3) <> "WD" Or .List(ri, 3) <> "DV" Or .List(ri, 3) <> "WV" Or .List(ri, 3) <> "WG" Then
            .RemoveItem ri
        End If
   Next
End With


Example: data
Column1                              Column2                           Column3
21212                                   apples                                           ST
21213                                   BREAD                                          DG
21299                                   PEANUTS                                       WG
21207                                   ORANAGE                                     ST
21215                                   PIZZA                                            ST
21201                                   TUNA                                           WV
21217                                   SUSHI                                         ST
21200                                   PAYDAY                                       DV
     
After I execute this code all that should be left is
Column1                              Column2                           Column3
21213                                   BREAD                                          DG
21299                                   PEANUTS                                       WG
21201                                   TUNA                                           WV
21200                                   PAYDAY                                       DV



BUT ALL THE DATA GETS deleted..??

Thanks
fordraiders
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 13 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 2 Answers and 13 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