+ Reply to Thread
Results 1 to 11 of 11

Combobox Multiple Selection

  1. #1
    Forum Contributor
    Join Date
    05-14-2019
    Location
    Alex, Egypt
    MS-Off Ver
    365
    Posts
    254

    Combobox Multiple Selection

    I have userform with several comboboxes and some of them are cascading comboboxes

    The problem that comboboxes allow only single selection from the dropdown list, is there any way to make multiple selection possible ?

    as shown in pic
    "sub parts" combobox is cascading from the "parts" combobox
    so i need multiple sellection from "parts" and so multiple selection for the cascading combobox

    parts.png

    is it possible or is there any alternative for the comboboxes ?
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Combobox Multiple Selection

    I don't think Excel Userform Combobox supports mutli-select (I believe Access 2007 introduced it, but it breaks first normal form of db structure... but that's another story).

    I'd recommend using ListBox instead with multi-select turned on.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Contributor
    Join Date
    05-14-2019
    Location
    Alex, Egypt
    MS-Off Ver
    365
    Posts
    254

    Re: Combobox Multiple Selection

    Listbox is a good option , but theres no place for listbox for every combobox

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Combobox Multiple Selection

    Sorry, can't help you there.

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

    Re: Combobox Multiple Selection

    Quote Originally Posted by Mahmoudelnemr View Post
    Listbox is a good option , but theres no place for listbox for every combobox
    How about something where the ListBox is hidden.
    The ComboBox Drop Button Click event makes it visible
    The ComboBox Exit event hides it again.

    The ListBox(s) don't clutter up the userform, they are only visible when the ComboBox drop down would have been.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Forum Contributor
    Join Date
    05-14-2019
    Location
    Alex, Egypt
    MS-Off Ver
    365
    Posts
    254

    Re: Combobox Multiple Selection

    Ok i made listbox with same values of the combobox, and allowed multiple selection
    the oint here that i have cascading combobox (sub parts), is there a way to make a cascading listbox with multible selection

    listttt.png
    cascading listbox works fine without multiple selection

    Please Login or Register  to view this content.
    when activating multiple selection cascading isnt possible
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    05-14-2019
    Location
    Alex, Egypt
    MS-Off Ver
    365
    Posts
    254

    Re: Combobox Multiple Selection

    Quote Originally Posted by mikerickson View Post
    How about something where the ListBox is hidden.
    The ComboBox Drop Button Click event makes it visible
    The ComboBox Exit event hides it again.

    The ListBox(s) don't clutter up the userform, they are only visible when the ComboBox drop down would have been.
    I have no idea how to make this, replacing the combobox by text box and when clicking the box the listbox pops up
    i tried to do this , could you help me with this
    https://www.excelforum.com/excel-pro...a-textbox.html

  8. #8
    Forum Contributor
    Join Date
    05-14-2019
    Location
    Alex, Egypt
    MS-Off Ver
    365
    Posts
    254

    Re: Combobox Multiple Selection

    Quote Originally Posted by Mahmoudelnemr View Post
    Ok i made listbox with same values of the combobox, and allowed multiple selection
    the oint here that i have cascading combobox (sub parts), is there a way to make a cascading listbox with multible selection

    Attachment 634425
    cascading listbox works fine without multiple selection

    Please Login or Register  to view this content.
    when activating multiple selection cascading isnt possible
    I hope theres a way to solve this

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

    Re: Combobox Multiple Selection

    I'll get back to this later this evening and post an example.

  10. #10
    Forum Contributor
    Join Date
    05-14-2019
    Location
    Alex, Egypt
    MS-Off Ver
    365
    Posts
    254

    Re: Combobox Multiple Selection

    thanks a lot

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

    Re: Combobox Multiple Selection

    Sorry for the delay. I learned some things.

    I had suggested a ComboBox+ListBox solution. But... when a combobox list is dropped down, it appears over all the other controls, so the ListBox cannot substitute for the dropdown, because the Listbox would be partially hidden.

    A ComboBox is a mix between a TextBox plus a list, where the user can either type the entry or select one item from a list.
    You want a multi-select option.
    So I created a custom control, clsMultiCombo, that combines a textbox and a ListBox to get that result.

    The .AddItem, .List, .ListIndex, .RemoveItem and .Selected properties (and others) of the clsMultiCombo mimic those of a ComboBox.

    There are a few properties and methods that are unique to a clsMultiCombo:

    .DropUp - closes the drop-down list

    .TextDisplayMulti - when the list is dropped up, if .TextDisplayMulti is False, the textbox will show the first selected item from the list. If True (the default), it will display a delimited string of all the selected items

    .Delimiter - is the delimiter used to create that delimited string. The default value is " ", but can be changed.

    The .Value property of clsMultiCombo is the delimited string of all selected items.
    The .Text property is the string currently displayed in the TextBox. Note the .Value and the .Text are the same if .TextDisplayMulti is True.

    The .MultiLine property of clsMultiCombo is sort of an Auto-Height for the textbox. (default - False)
    if .MultiLine = True the textbox will expand in height to show all of the .Text value
    if .MultiLine = False the textbox will retain its size and some might run out the sides.

    The attached file has a userform with a clsMultiCombo control and some other controls to show how these properties work.

    To use clsMultiControl, one creates an instance and then sets the .TextBox property to an existing textbox.
    Only after the .TextBox property is set does one start filling boxes etc.

    NOTE: a ComboBox allows for the user to type into the box as well as select a single item from a list. But with multiple selection, how to interpret user typed values is a problem. So, currently, clsMultiCombo will only accept selection from the list. Typing into the textbox has no result. i.e. the .Style is fixed at fmStyleDropDownList.

    NOTE 2: custom classes do not respond to Exit, BeforeUpdate or AfterUpdate events. So clsMultiCombo does not "know" for sure when the control has the focus, which leaves the dropdown list open. To close the dropdown list, the user either clicks on the drop button or they tab out of the control.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Populate multiple TextBoxes based on ComboBox Selection
    By PTechFL in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-23-2019, 06:35 AM
  2. countif across multiple worksheets based on combobox selection
    By bqheng in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2018, 10:18 PM
  3. Populate multiple textboxes after selection from a single combobox
    By VaibhavAr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2016, 07:34 AM
  4. Combobox Multiple Selection or Listbox Dropdown
    By mattydalton in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-29-2014, 11:30 AM
  5. [SOLVED] fill combobox selection based on a selection from the first combobox
    By Monza in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-14-2013, 07:34 PM
  6. Generate multiple OptionButtons with combobox selection
    By fmluder93 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2013, 05:20 AM
  7. ActiveX ComboBox selection writes multiple cells
    By darmstrong in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-30-2007, 10:31 PM

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