+ Reply to Thread
Results 1 to 2 of 2

Populate ListBox from Table and perform Filter based on CommandButtons

  1. #1
    Registered User
    Join Date
    05-12-2020
    Location
    Wales
    MS-Off Ver
    365
    Posts
    82

    Populate ListBox from Table and perform Filter based on CommandButtons

    Can anyone help me.

    I'm trying to populate a ListBox from a Table and then use CommandButtons to filter the entries that are displayed in the ListBox.

    I've read of various ways to populate the ListBox and even managed to perform filters but I simply don't understand the code and the more I read and tried different things the more confused I became.

    For instance I know I can populate the ListBox using the Rowsource feature but understand that it shouldn't be used, but I can't seem to find the reason why that is the case.

    I've attached a workbook with the basic elements in it but no code. Can someone please point me in the right direction? I don't mind doing the leg work in order to try and figure things out but as I've said, the more I look the more I'm getting overwhelmed.

    I guess this seems like i'm too lazy to work it out myself but it is what it is.

    Thank you.
    Attached Files Attached Files

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

    Re: Populate ListBox from Table and perform Filter based on CommandButtons

    Attached small demo using your form.
    Selection in listbox will populate the bottom three textboxes.
    Also pressing each of the command buttons will fill the top three label boxes.
    All the listbox settings are set up in the UserForm initialize event.
    The table is loaded to an array and this is used to populate the listbox.
    With an array this remains in memory and can be accessed without need to read the sheet.
    The reason rowsource is not used for serious apps lies with the fact data is moved back and forth to the sheet at every activation of the listbox.
    This in itself is inefficient in larger apps and has proven to be unstable for reasons I am not sure of(probably stack overload).
    Look through the code, any problems post back on this site, hope this is of some small help.
    torachan.
    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 second listbox based on selection in first listbox
    By muse95 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2017, 06:04 PM
  2. Populate (ca 200) Txtboxes depending on listbox selection, live-filter for listbox &1 more
    By InternInNeed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-14-2016, 09:56 AM
  3. Populate multiple filter listbox - Problem
    By rukman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-07-2016, 05:10 PM
  4. VBA - Populate Listbox based on value selected in another ListBox (On Userform)
    By raaboo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-12-2012, 11:18 AM
  5. Populate userform listbox based on value selected in another listbox
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2012, 05:16 PM
  6. Populate ListBox Based On Item Chosen In Another ListBox
    By davemojo82 in forum Excel General
    Replies: 1
    Last Post: 08-04-2009, 08:39 AM
  7. populate listbox based on selection in previous listbox
    By sarahng86 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2007, 10:55 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