+ Reply to Thread
Results 1 to 5 of 5

Use a filtered range as a Listbox RowSource

  1. #1
    Registered User
    Join Date
    05-20-2016
    Location
    Alicante, Spain
    MS-Off Ver
    Microsoft Excel 2007
    Posts
    6

    Use a filtered range as a Listbox RowSource

    Good morning everyone,

    I have a worksheet that processes sales. If you click the Product Code cell in a new line, a userform pops up, containing a ListBox of all the products in the warehouse, then you double click one of them and it gets added to the invoice.

    My problem comes because this ListBox will always show every single row in the warehouse sheet no matter what I do with its RowSource, and I want to only show products with a remaining quantity >0 and some other filter criteria added in there too.

    This is the current code for my form:
    Please Login or Register  to view this content.
    This returns every single row, no matter if autofiltered or not. I've tried SpecialCells(xlCellTypeVisible) but I must have used it wrong because all I get is a blank listbox. The plan is to add ws1.AutoFilter.ApplyFilter before defining the RowSource to always get up-to-date data, would it work?

    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Use a filtered range as a Listbox RowSource

    Maybe this helps to get you on the right direction


    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-20-2016
    Location
    Alicante, Spain
    MS-Off Ver
    Microsoft Excel 2007
    Posts
    6

    Re: Use a filtered range as a Listbox RowSource

    Hello Leo,

    Thank you so much for taking the time to make this! However, it isn't exactly what I'm looking for.

    I've tried to make a copy of my workbook stripping out all sensitive information to see if it helps make the problem clearer.

    If you try clicking on any cell under "IDCaja" on the second sheet, you'll be presented with my current userform. There are two columns for "Total units" and "Sold units" plus a third one for "Remaining units" which is Total-Sold.

    What I want to do is just make it so if Remaining Units = 0, that particular row doesn't appear (I made several articles have a remaining total of 0 for the example, from ID 86 to 99).

    Or maybe your solution IS the answer I'm looking for, but I don't have the clarity of mind to understand the code very well, since I've been running without coffee all morning and the effects start to show -_- so I'll come back to this again in a couple hours and tell you if I managed to adapt it to my workbook!

    Thanks again for your dedication!

    Kichen
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Use a filtered range as a Listbox RowSource

    For Userform Initialize

    Please Login or Register  to view this content.
    Kind regards
    Leo

  5. #5
    Registered User
    Join Date
    05-20-2016
    Location
    Alicante, Spain
    MS-Off Ver
    Microsoft Excel 2007
    Posts
    6

    Re: Use a filtered range as a Listbox RowSource

    Got a type mismatch error at the beginning. Then, I fixed all my source data by checking that no cells returned any #N/A error (it's all formulas) adding IFERROR() to all of them, and now it works like a charm! Thank you so much Leo, you're a savior :D marking this as solved!

+ 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 ListBox with Filtered Range
    By smartbuyer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2015, 01:09 AM
  2. [SOLVED] Code help: Copy only filtered range to ListBox
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 02-06-2015, 04:50 AM
  3. [SOLVED] ListBox rowsource named range offset by 1
    By Taemex in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2014, 03:17 AM
  4. [SOLVED] VBA: UserForm ListBox Column Headings RowSource = Named Range
    By Hudas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2012, 02:21 AM
  5. Listbox w/ Range.name rowsource only displaying 6 of the 8 range elements
    By jazaddict in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-29-2009, 05:06 PM
  6. range name as rowsource of listbox?
    By Stefi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2006, 09:30 AM
  7. Filtered List as Listbox RowSource
    By Ken McLennan in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-20-2005, 08:05 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