+ Reply to Thread
Results 1 to 8 of 8

VBA - Store selected items in listbox

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    VBA - Store selected items in listbox

    Hi!

    I have a listbox with a couple of items in a vba userform. I want to store the selected items in an array or something when i hit a button. Is this something you could help me with? I would very much appreciate it. Thank you

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA - Store selected items in listbox

    Perhaps something like this

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    09-19-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: VBA - Store selected items in listbox

    Thanks for your quick reply. I have highlighted problems i have with the code.

    Please Login or Register  to view this content.
    I was also wondering how to use debug.print to check it out in the immediate window. Thanks so much for your help so far.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA - Store selected items in listbox

    Sorry that should be
    Please Login or Register  to view this content.
    and .ListCount.

    as for debugging, putting
    Please Login or Register  to view this content.
    would be one way.

  5. #5
    Registered User
    Join Date
    11-08-2015
    Location
    Brazil
    MS-Off Ver
    Office 2016
    Posts
    4

    Re: VBA - Store selected items in listbox

    Hi,
    I have a similar question to this but with a slight twist:
    Im working with a multiselect listbox and I want to store the index of the selected items into an array instead of the value of the selected items.

    I have tried using the Listindex, but I cant make it read all of the selected items index. It only reads the index of the first selected item.

    Hopefully someone can help me!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: VBA - Store selected items in listbox

    Welcome to the forum Pamela2411


    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  7. #7
    Registered User
    Join Date
    11-08-2015
    Location
    Brazil
    MS-Off Ver
    Office 2016
    Posts
    4

    Re: VBA - Store selected items in listbox

    Sorry! Will do so

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: VBA - Store selected items in listbox

    No problem. Sure you'll get a great response.

    Regards, TMS

+ 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