Results 1 to 4 of 4

VBA: How to clear listbox items?

This is a discussion on VBA: How to clear listbox items? within the Excel Questions forums, part of the Question Forums category; Hi all, I have a simple question. How does one clear a listbox with VBA ? Thanks...

  1. #1
    Board Regular dbmathis's Avatar
    Join Date
    Sep 2002
    Location
    Austin, Texas USA
    Posts
    1,064

    Default VBA: How to clear listbox items?

    Hi all,

    I have a simple question. How does one clear a listbox with VBA?

    Thanks
    After all this is over, all that will really have mattered is how we treated each other.

    Excel Version: 2007
    OS: Windows 7

  2. #2
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    64,939

    Default

    What do you mean by clear?

    Clear the contents?
    Code:
    Listbox1.Clear
    Clear the selection(s)?
    Code:
    Listbox1.ListIndex = -1
    If posting code please use code tags.

  3. #3
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    64,516

    Default

    If it's filled with AddItem:

    ListBox1.Clear

    If it's filled with RowSource:

    ListBox1.RowSource = ""

  4. #4
    Board Regular dbmathis's Avatar
    Join Date
    Sep 2002
    Location
    Austin, Texas USA
    Posts
    1,064

    Default

    Hmmm. It was actually filled with an array. I tried .clear before I posted and it didn't work? Now it does? Must have been a typo.

    Thanks for the prompt response.
    After all this is over, all that will really have mattered is how we treated each other.

    Excel Version: 2007
    OS: Windows 7

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com