+ Reply to Thread
Results 1 to 8 of 8

Filter by a Selected List

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Filter by a Selected List

    I have a good start on a macro I'm developing (code at bottom). What it currently does is to filter the hardcoded range by the list I select. Good so far. What I want to add, and am not sure how to do, is:
    1) Allow the filtering of the Activesheet by a list on another sheet.
    2) Allow me to select the range on my activesheet to filter. For instance, if my table lives in c10:H99999 I don't want to apply a filter at A1.

    Not sure how to plumb all that into my code, so coming here for help. Thanks in advance.

    Please Login or Register  to view this content.
    I know I'm not stupid, but I suspect I'm a lot stupider than I think I am

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Filter by a Selected List

    Hi jomili

    Change this to the Code Name of the Sheet you wish to Filter...
    Please Login or Register  to view this content.
    Create a Named Range of this list (make it Dynamic)...call it whatever you wish...
    a list on another sheet.
    In the Code change this to your Named Range...
    Please Login or Register  to view this content.
    In the Code Set the Range & Column to be Filtered
    Please Login or Register  to view this content.
    Complete Code...
    Please Login or Register  to view this content.
    Last edited by jaslake; 12-04-2017 at 08:56 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by a Selected List

    jaslake,

    I apologize if my description of the project wasn't descriptive enough. I appreciate your efforts, but it's not in line with my ultimate goal here. The idea is a repeatable macro where I can autofilter a selected column range (which would be in a different place, different size each time) by a list that may or may not be in the same worksheet or workbook. So, ideally I'd need two prompts, one to pick the Data, including the column to filter, and the other to pick the list to filter by. So, in my original code, I DIMMED SRC and Targ as worksheets, but didn't use them. My thought is SRC would be the list to use (to filter by), and Targ would be the datatable to filter, then we'd have to narrow in on the column to filter.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Filter by a Selected List

    Hi,

    Perhaps this?
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by a Selected List

    Awesome! that's spot on, exactly what I was trying to do. I've tested it with filters on, with filters off, and with a table, and it performs flawlessly so far. Thank you. I'll be using this one often.

    In case you're interested, the reason I wanted to develop this is because I have Jeff Weir's code for filtering a pivot from http://dailydoseofexcel.com/archives...xternal-range/ and I use it every day. So, when I go to a regular data table and want to filter it, often it's by a list I've saved in another workbook, so by habit I try to do the right-click and filter by the list, but Jeff's code only works for Pivot tables. Now thanks to you I have the code to do it for any table/Range.

    My next step is how to plumb this into my right-click menu, so off I go in search of a solution to that.

    Thanks, God bless you, and Merry Christmas!

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Filter by a Selected List

    You can adapt his AddRightClick routine but use
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by a Selected List

    FYI that I changed the Filter macro as shown below to use the CurrentRegion and the Activecell. In this way, I click into the table I want to filter. CurrentRegion defines the parameters of my data source, and the active column is the one I want to filter. So the only InputBox needed is for the list. So far seems to be working fine.
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by a Selected List

    just realized I never put the full code for this project, so I've put it all below:
    Please Login or Register  to view this content.

+ 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. Drop Down List with Filter and the Filter list in one single column
    By wpm7113 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-28-2016, 06:38 AM
  2. How to replace drop down list filter to those normal excel filter?
    By cks1026 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-24-2016, 02:48 AM
  3. Macro to filter a pivot whilst looping through filter criteria in a variable list.
    By Alistairm88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2015, 04:25 AM
  4. Replies: 0
    Last Post: 01-16-2014, 10:55 AM
  5. Filter List Results Dependent on another Filter List
    By Owlsfan in forum Excel General
    Replies: 2
    Last Post: 04-28-2013, 06:20 PM
  6. Replies: 1
    Last Post: 06-05-2006, 03:55 PM
  7. Replies: 3
    Last Post: 05-19-2005, 08:06 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