+ Reply to Thread
Results 1 to 4 of 4

preselect ALL items in Listbox

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    preselect ALL items in Listbox

    I have a Listbox with a varying number of items in the list.
    90% of the time the user will select all the items in the list.
    Is there a way to have all the items preselected?
    Then the remaining 10% can unselect.
    Last edited by carsto; 09-17-2009 at 11:58 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: preselect ALL items in Listbox

    Hello ,

    Here is an example. You will need to change the ListBox name if it is different than yours.
      For I = 0 To ListBox1.ListCount - 1
        ListBox1.Selected(I) = True
      Next I
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: preselect ALL items in Listbox

    Good afternoon carst
    Quote Originally Posted by carsto View Post
    Is there a way to have all the items preselected?
    Then the remaining 10% can unselect.
    Are we talking about a listbox in a userform?
    If so use the code below (I'm assuming that your listbox is called ListBox1) :
    For n = 0 To ListBox1.ListCount - 1
    ListBox1.Selected(n) = True
    Next n
    Just make sure that your listbox is set up to accept multiple selections.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: preselect ALL items in Listbox

    Thank you both

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1