+ Reply to Thread
Results 1 to 13 of 13

Thread: Filter based on what's in another filter list

  1. #1
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    21

    Filter based on what's in another filter list

    Hello,

    I have a front sheet with a bunch of validation-list-drop-downs. When the user selects combinations of these and then runs a macro, a table on the second sheet is filtered by those criteria. Each row has a unique ID, let's called it the Sweet ID.

    There is another third sheet which has more data (one row per Sweet ID, but with a different bunch of columns).

    Here's what I would like to do: Run the macro which filters the second sheet, takes those Sweet IDs and then uses those to fitler the third sheet.

    Grateful for any help. Thanks,

    HE.
    Last edited by headexperiment; 08-22-2011 at 12:02 PM. Reason: Solved

  2. #2
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Filter based on what's in another filter list

    Just to clarify - I already have the first bit sorted which filters the second sheet. It's the final step I need help with. Thanks.

  3. #3
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Filter based on what's in another filter list

    Bump. Grateful for any help the experts can offer. Thanks.

  4. #4
    Valued Forum Contributor
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2003
    Posts
    2,488

    Re: Filter based on what's in another filter list

    hi, headexperiment, is there any chance to see a sample workbook showing original data and result you need to obtain?

  5. #5
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Filter based on what's in another filter list

    Quote Originally Posted by watersev View Post
    hi, headexperiment, is there any chance to see a sample workbook showing original data and result you need to obtain?
    Hi watersev, Thanks for your reply. the file I'm working on contains senstive data so I'll just need to recreate it in an anonymous format first, and then I'll post it. BRB. Thanks. HE.

  6. #6
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Filter based on what's in another filter list

    Hello,

    I've anonymised the workbook I'm working on. Grateful for any help. To recap- I want to take the Sweet IDs left after filtering the List sheet, and use those IDs to filter the M sheet.

    Thanks,

    HE
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2003
    Posts
    2,488

    Re: Filter based on what's in another filter list

    please check attachment, run code "test"
    Attached Files Attached Files

  8. #8
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: Filter based on what's in another filter list

    Hi HE

    Try this code
    Option Explicit
    Sub Test()
        Dim LR As Long
        Dim LRm As Long
        Dim LRf As Long
        Application.DisplayAlerts = False
        Sheets("Fdata").Delete
        Application.DisplayAlerts = True
        Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Fdata"
        With Sheets("List")
            LR = .Range("A" & .Rows.Count).End(xlUp).Row
            .Range("A11:A" & LR).SpecialCells(xlCellTypeVisible).Copy
            Sheets("Fdata").Range("A1").PasteSpecial
            Application.CutCopyMode = False
        End With
        LRf = Sheets("Fdata").Range("A" & Rows.Count).End(xlUp).Row
        With Sheets("M")
            .AutoFilterMode = False
            LRm = .Range("A" & .Rows.Count).End(xlUp).Row
            .Range("A9:A" & LRm).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
                    Sheets("Fdata").Range("A1:A" & LRf), Unique:=False
            .Activate
        End With
    End Sub
    Let me know of issues.
    Attached Files Attached Files
    Last edited by jaslake; 08-18-2011 at 04:27 PM. Reason: Attach File
    John

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

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

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

  9. #9
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: Filter based on what's in another filter list

    Hi HE
    Hope you don't mind...I've rewritten the code for your "Reset All" button. If you like it use it...if not lose it
    Sub showall()
        Dim Rng As Range
        With Sheets("Front")
            On Error Resume Next
            Set Rng = Union([Option_att_flag], [Option_prog_flag], [Option_proj_flag], [Option_pp_flag], _
                    [Option_20plus_flag], [Option_10plus_flag], [Option_5plus_flag], [Option_age], [Option_type], [Option_ccc])
            Rng.Value = "Any"
            On Error GoTo 0
        End With
        With Sheets("List")
            If .FilterMode Then
                .ShowAllData
            End If
        End With
        With Sheets("M")
            If .FilterMode Then
                .ShowAllData
            End If
        End With
    End Sub
    John

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

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

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

  10. #10
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Filter based on what's in another filter list

    Hi Jaslake and Watersev,

    Apologies didn't get back to you lastw week. Many thanks for your help looking into this. I'll have a play and let you know what I find.

    Thanks,

    HE

  11. #11
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Filter based on what's in another filter list

    @Jaslake

    on error resume next
    Sheets(array("List","M")).showalldata



  12. #12
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Filter based on what's in another filter list

    Thanks John,

    Seems to work ok. Must confess I don't understand the intricacies of whether the code lives in ThisWorkbook or in a module, but is it possible to combine the new test() code with the existing filtersheets() code, so it all works together?

    Cheers, HE

  13. #13
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Filter based on what's in another filter list

    Big thanks to @jaslake and @watersev. With a bit of tweaking I've got this doing exactly what I want.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0