+ Reply to Thread
Results 1 to 22 of 22

ListBox in UserForm with multiple drop down entries

  1. #1
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Question ListBox in UserForm with multiple drop down entries

    Hi All,

    As per the attached image example, you will see 3 example entries filled in my userform - I have show an image as well as to how it looks when entered into the table.

    I want to find out if it's possible to have a drop down box in the 'listbox' that allows me to select the relevant name and when I move down to the next line another drop down will appear for me to add the next etc...

    The names can be fairly long and have many, so having a dropdown will avoid manually typing and user prone errors.

    Thanks in advance.
    Last edited by MyForcey; 10-21-2021 at 03:43 AM.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: ListBox in UserForm with multiple drop down entries

    Listboxes don't, and can't, have dropdowns. I'd suggest a separate control (either listbox or combobox) where you can select your reinsurer(s) and then use a button to add them to the list of applicable markets.
    Rory

  3. #3
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    Hi, thanks, okay how do I do that so it enters the data in the format I currently have? The current box is a 'listbox'.
    Unless you know of a completely different way I could do this?

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: ListBox in UserForm with multiple drop down entries

    Add the other control (listbox or combobox) with all the available reinsurers listed in it, then your button simply needs to do something like:

    Please Login or Register  to view this content.
    where listbox1 is your current listbox and combobox1 is the name of the new control.

  5. #5
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    Where do I add the other control? Could I list them on the sheet and reference it to that?

    This is my code for adding from new:
    Please Login or Register  to view this content.
    This is the code for when I amend:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: ListBox in UserForm with multiple drop down entries

    Add the other control to your form somewhere appropriate. Yes, you can list them on a sheet then populate the control in the Userform_Initialize event using something like:

    Please Login or Register  to view this content.
    for example.

  7. #7
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    I replaced the textbox with a listbox, kinda stuck from there. Can list the few I've tried, not sure how to select the ones and keep them in the form. Are you refereeing to adding another button?

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: ListBox in UserForm with multiple drop down entries

    How are you storing the data? Is it all going in one cell?

  9. #9
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    Correct - Is there another way to store it? only the 'reinsurers' part consists of 1 or more entries, and each 'risk' is in a row (have attached example picture) also what if I need to enter a percentage per each? (see the yellow row), unless that just complicates thing too much.

  10. #10
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ListBox in UserForm with multiple drop down entries

    @MyForcey, please make this easier for a solution to be given by reading the big yellow banner and upload your workbook.
    This is the type of query that should be solved by post #2 if all the detail is presented at the outset.
    By the nature of responses it is obvious you need deeper understanding of VBA process.
    Please help us to help you - upload that workbook before any more questions.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  11. #11
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    I'm sorry, I don't understand what's not clear. Apologies for my ignorance.
    I have attached the workbook accordingly.

  12. #12
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ListBox in UserForm with multiple drop down entries

    i have only made changes with userform1 code.
    however your main database was a table, therefore use table referencing methods not range referencing.
    if you are adopting tables use them throughout your app, i have altered the loading lists to the comboboxes and listbox to table format.
    the listbox is multi-select and will save as a multi-row cell - i assume that any percentage would need to be variable - if so that would be more complex.
    give it a trial - i have not included any error checking for date formats etc.,
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    Hi there, apologies for the delay. I went though it now and it indeed does what I was looking for, thank you.

    Of course I'm still an amateur at VBA and only just learnt how to use range referencing, I appreciate informing me the better option and amending my workbook, however I'm now unsure on how to fix up my amend form since the referencing has all changed? The form will populate with the selected cell - but I still want to use the multi-select listbox?
    Is there a formula I can apply to your new code that I can replace the current code with?
    With the percentage, I'm good with leaving it as is - Will look into the variable thing you mentioned with that.

    The code you wrote to add to a new row:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    The code I have to amend a selected row:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  14. #14
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ListBox in UserForm with multiple drop down entries

    give the attached a try, bit of a pain dealing with the multi row cell.
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    Hi, thank you, however it was not loading right. and an added combo box for some reason?
    I've attempted a few times with naming etc but no luck... I've changed a few things. do you mind having a look at this copy (attached)?
    should be able to use the "UserForm1" code and just have it so that the fields in the "UserForm3" will auto populate depending on the row I've selected?

    Please shout if you require more information from me.

    The "reinsurers" field (I.e the multi-row) - that does not need populating only the other fields (I just need the option as in UserForm1 to select the reinsurers).

    Much appreciated.
    Last edited by MyForcey; 10-20-2021 at 03:41 AM.

  16. #16
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ListBox in UserForm with multiple drop down entries

    I will bow out at this stage - the app is becoming a patch work of methodology.
    Firstly I do not attempt mixing on sheet formula/formatting/conditional formatting/data validation with VBA UserForms.
    The sheet is used as a data store(pseudo database) all other actions to take place within the code - remove all the ActiveX buttons from your sheet.
    Data handle with a single UserForm - eliminate repetitious code - do not extend data tables below the last row of data.
    The extra combobox enables you to search for your file without bouncing back and forth between forms.

  17. #17
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    Okay sorry I don't understand half of what you said .

    I've managed to get it how I want, my only issue now is that the selected items aren't being added to the cell? (Code below) - so just need the 'reinsurers' part to update the cell (multi-row cell).

    This has taken me over a year to get this far, I doubt I can redo everything to match your recommendations, appreciated but far beyond my capabilities.

    Please Login or Register  to view this content.

  18. #18
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ListBox in UserForm with multiple drop down entries

    re-read post#12, you are using tables, therefore read-up on their useage, do not develop a 'hodge-podge' mix of tables and range referencing.
    you can not simply paste a block of code from my app into your app and expect it to work, you need common foundations.
    simple things need progressive alteration, simple example, the tables that load your comboboxes have a cluster of empty rows at the bottom of the table.
    now look at your listbox, this has the effect of loading your listbox with numerous rows of 'nothingness' , now delete the empty rows from the tables and 'nothingness' dissappears.
    I would be doing you a dis-service if I solved individual items without considering the overall app and its future stability and suitability.

  19. #19
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    Sorry, I do not know what that means.

    The "nothingness" of empty rows is in the example workbook only, not in my workbook.

    This is purely for my own use, I don't require future stability or suitability.

    How can I make selected items in a listbox to add to a single cell where each selection (if applicable) goes on the next line within the same cell.
    - This is where I get confused with your code - I don't understand which part adds the selections in the listbox to the cell underneath one-another.

  20. #20
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Unhappy Re: ListBox in UserForm with multiple drop down entries

    I've been trying many variations now.

    This change from range to tables has confused me, I only just learnt how to do the one... is there a way to do the 'listbox multiselect to cell' using range instead?
    Attached Files Attached Files

  21. #21
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ListBox in UserForm with multiple drop down entries

    you do not mix 'tables' and 'ranges' use one or the other - your main database is a 'table' - learn the correct referencing syntax.
    the attached file is your app simplified and condensed to one form - the code is annotated for you to follow and the pdf has the code layout so that you can follow the loops and code flow - you should not be confused if you read it through several tmes.
    Attached Files Attached Files

  22. #22
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    101

    Re: ListBox in UserForm with multiple drop down entries

    Hi, thank you.
    I had a brief look now, I highly appreciate the effort you put in and trying to inform me of how things should be done.

    I will follow the pdf accordingly.

    Thank you for the effort and time.
    Last edited by MyForcey; 10-24-2021 at 02:47 PM.

+ 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. Filtering a listbox from multiple entries in combo-boxes
    By JonnyAngelo in forum Excel General
    Replies: 0
    Last Post: 01-05-2018, 10:07 AM
  2. [SOLVED] Display column entries in row as vertical entries in a userform listbox
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-22-2016, 08:10 AM
  3. Checkbox on a Userform that selects all entries of a Listbox
    By dutchcourage in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2015, 08:09 AM
  4. userform listbox
    By tsiguy96 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-14-2013, 11:09 PM
  5. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  6. [SOLVED] Populate listbox columns with entries from textboxes on userform
    By AndyE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2012, 11:05 PM
  7. Transferring Data from Userform Listbox to Drop-down list in Worksheet
    By f5awp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-30-2011, 12:22 AM

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