Populate Listbox with filtered data

  • I have been trying everything on the internet for the last 2 weeks to find a solution to a seemingly easy problem. Maybe I am looking down the wrong path. Hope someone can chime in with some advice. Heres what I am trying to accomplish.


    I have a userform multiselect listbox populated by rowsource in VBA that shows 12 columns per row (It intentionally does not show the 13th column). I would like to filter the table on sheet "ms" to only populate the listbox with all rows that are blank in column 13. Currently I am using autofilter to send the filtered data to a helper sheet and populating the listbox from there. Is it even possible to avoid using the helper sheet? The reason I want to do this is when I select rows in the listbox, it is supposed to add an "X" in column 13. What is happening is the row index on the Original table does not correspond with the filtered data so it puts the "X" on the wrong row if at all. Here is a quick mockup.


    [ATTACH=CONFIG]72952[/ATTACH]


    I just for the life of me cannot figure out how to accomplish this in each selected row. Can anyone help me?

  • Re: Populate Listbox with filtered data


    You should upload a sample workbook instead of image to work with.
    Also when you select a row in the listbox, how do you identify which row on the sheet is to be updated with a "x" in column 13? Do you have any column with a primary key?

    Regards.
    sktneer

  • Re: Populate Listbox with filtered data


    Quote from sktneer;795074

    You should upload a sample workbook instead of image to work with.
    Also when you select a row in the listbox, how do you identify which row on the sheet is to be updated with a "x" in column 13? Do you have any column with a primary key?

    I cannot upload the actual workbook due to sensitive data, however I stripped everything out of it and am attaching it. The userform has an error now that I deleted a bunch of stuff but will give you an idea of what I was doing as opposed to how I should be doing it. This is how I select the row to be updated:


    forum.ozgrid.com/index.php?attachment/72960/

  • Re: Populate Listbox with filtered data


    Quote from royUK;795075

    Take a look at this example


    Thank you for that. I took a look and its a bit above my head so to speak as I am quite the beginner. I am trying to see how to apply it to my needs, I will keep looking through it in the meantime.

  • Re: Populate Listbox with filtered data


    Under UserForm Initialize Event code, you may try something like this to populate the listbox to show the rows where column 13 is blank.
    See if you can incorporate this approach to your code.

    Regards.
    sktneer

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!