Results 1 to 4 of 4

Thread: Excel VBA Multiple Selection Listbox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2014
    Posts
    74

    Excel VBA Multiple Selection Listbox

    I'm using the Form Control List Box via the Developer Tab and I'm trying to figure out a code to take my selections (multiple selection list box) and display them in a single cell with the selections separated by a comma.

    When I right click the list box and navigate to the "Format Control" option, I get the option to make the list box a multi-select list box. Name:  Format_control1.jpg
Views: 4554
Size:  21.5 KB

    However the selections default to "0" and I cannot figure out how to get the selections to display into cell G9 as follows:

    "SelectionItem1, SelectionItem2, SelectionItem5, SelectionItem7..." [based on selections; into a single cell]

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Excel VBA Multiple Selection Listbox

    as far as i am aware, you would need to use an activex listbox

    a forms listbox in multiselect mode is only useful for visual return
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2014
    Posts
    74

    Re: Excel VBA Multiple Selection Listbox

    What would the use of a "visual return" offer? I know I can create a userform and code it accorndingly, but there has to be a way to do this with the listbox; the information has to go somewhere.

    Why does the reference cell default to "0" when multiple is selected? is the zero useful somehow?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Excel VBA Multiple Selection Listbox

    I know I can create a userform
    why can you not put an activex listbox on you worksheet?

    Why does the reference cell default to "0" when multiple is selected? is the zero useful somehow?
    no, the normal return to the linked cell is the index of the selected list item, the way it works can only be with a single returned value, not multi select
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width