how to clear all items in listbox in VBA?

Posted on 2006-05-12
Last Modified: 2008-01-09
in VBA, how can i remove all items in listbox object?
I don't know number of items.
Question by:yadafarin
    LVL 65

    Expert Comment

    is it bounded?
    if so, set rowsource to ""

    e.g. listbox.rowsource = ""
    u may need to refresh/requery it


    Author Comment

    no, it hasn't rowsource.
    I add items in listbox by VBA code (with .Additems).
    LVL 65

    Accepted Solution

       For i = List2.ListCount - 1 To 0 Step -1
            List2.RemoveItem i
        Next i
    LVL 65

    Expert Comment

    did this work

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now