+ Reply to Thread
Results 1 to 3 of 3

Help! Filtered Data in Listbox

  1. #1
    Registered User
    Join Date
    03-17-2005
    Posts
    5

    Help! Filtered Data in Listbox

    I want to show only the filtered data from a range in a listbox.

    The filtered data will not be only one row of data but a variable number of rows.

    Thanks,

    S

  2. #2
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Assumptions:

    1) Sheet1!A1:C5 contains the source data

    2) First row contains your headers/labels

    3) Column B contains the data you wish shown in your list box

    Formulas:

    On Sheet2, enter the following...

    A1: enter a 0 (zero)

    A2, copied down:

    =IF((Sheet1!A2<>"")*(SUBTOTAL(3,Sheet1!A2)),LOOKUP(9.99999999999999E+307,$A$1:A1)+1,"")

    B1:

    =LOOKUP(9.99999999999999E+307,A:A)

    C2, copied down:

    If Column B contains text values...

    =IF(ROW()-ROW(C$2)+1<=$B$1,INDEX(Sheet1!B:B,MATCH(ROW()-ROW(C$2)+1,A:A,0)),0)

    If Column B contains numeric values...

    =IF(ROW()-ROW(C$2)+1<=$B$1,INDEX(Sheet1!C:C,MATCH(ROW()-ROW(C$2)+1,A:A,0)),"")

    Define the following reference...

    Insert > Name > Define

    Name: ListBox (or any other name you wish)

    Refers to:

    If Column B contains text values...

    =OFFSET(Sheet2!$C$2,0,0,COUNTA(Sheet2!$C$2:$C$65536)-COUNT(Sheet2!$C$2:$C65536))

    If Column B contains numeric values...

    =OFFSET(Sheet2!$C$2,0,0,COUNT(Sheet2!$C$2:$C$65536))

    Lastly, enter the defined name ListBox as the Input Range for your list box.

    Now, when you filter your main data on Sheet1, your list box should change accordingly.

    Hope this helps!
    Last edited by Domenic; 03-17-2005 at 07:32 PM.

  3. #3
    Registered User
    Join Date
    03-17-2005
    Posts
    5
    I should have been more clear.

    I am writing an macro in VBA. I have a range of data that is filtered. I want that filtered data to be listed in my listbox within a userform.

    For Example, I have a range of names of people who work at different companies. When I click on one of the companies in my userform. I want all the names of people associated with that company to appear in the listbox.

    S

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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