Consulting

Results 1 to 9 of 9

Thread: Filter Excel Data using vba Multiple Columns Multiple Criteria

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,970
    For others, cross-posted at http://www.mrexcel.com/forum/excel-q...-criteria.html
    For pmyk/pmich, see attached, wheerin macros:
    Sub Macro1()
    ss = "Ben"
    tt = "254365"
    uu = "College"
    vv = "School"
    ww = "Office"
        Range("I15").Formula = "=AND(SEARCH(""" & ss & """,B2)=1,F2=""" & tt & """,OR(ISNUMBER(SEARCH(""" & vv & """,C2)),ISNUMBER(SEARCH(""" & uu & """,C2)),ISNUMBER(SEARCH(""" & ww & """,C2)),ISNUMBER(SEARCH(""" & vv & """,D2)),ISNUMBER(SEARCH(""" & uu & """,D2)),ISNUMBER(SEARCH(""" & ww & """,D2)),ISNUMBER(SEARCH(""" & vv & """,E2)),ISNUMBER(SEARCH(""" & uu & """,E2)),ISNUMBER(SEARCH(""" & ww & """,E2))))"
        'Range("I15").Formula = "=AND(SEARCH(""Ben"",B2)=1,F2=""254365"",OR(ISNUMBER(SEARCH(""School"",C2)),ISNUMBER(SEARCH(""College"",C2)),ISNUMBER(SEARCH(""Office"",C2)),ISNUMBER(SEARCH(""School"",D2)),ISNUMBER(SEARCH(""College"",D2)),ISNUMBER(SEARCH(""Office"",D2)),ISNUMBER(SEARCH(""School"",E2)),ISNUMBER(SEARCH(""College"",E2)),ISNUMBER(SEARCH(""Office"",E2))))"
        Range("A1:F5").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("I14:I15"), CopyToRange:=Range("P1"), Unique:=False
    End Sub
    and
    Sub Macro3()
    ss = "Ben"
    tt = "254365"
    uu = "College"
    vv = "School"
    ww = "Office"
        Range("I15").Formula = "=AND(SEARCH(""" & ss & """,B2)=1,F2=""" & tt & """,OR(ISNUMBER(SEARCH(""" & vv & """,C2)),ISNUMBER(SEARCH(""" & uu & """,C2)),ISNUMBER(SEARCH(""" & ww & """,C2)),ISNUMBER(SEARCH(""" & vv & """,D2)),ISNUMBER(SEARCH(""" & uu & """,D2)),ISNUMBER(SEARCH(""" & ww & """,D2)),ISNUMBER(SEARCH(""" & vv & """,E2)),ISNUMBER(SEARCH(""" & uu & """,E2)),ISNUMBER(SEARCH(""" & ww & """,E2))))"
        'Range("I15").Formula = "=AND(SEARCH(""Ben"",B2)=1,F2=""254365"",OR(ISNUMBER(SEARCH(""School"",C2)),ISNUMBER(SEARCH(""College"",C2)),ISNUMBER(SEARCH(""Office"",C2)),ISNUMBER(SEARCH(""School"",D2)),ISNUMBER(SEARCH(""College"",D2)),ISNUMBER(SEARCH(""Office"",D2)),ISNUMBER(SEARCH(""School"",E2)),ISNUMBER(SEARCH(""College"",E2)),ISNUMBER(SEARCH(""Office"",E2))))"
        Range("A1:F5").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("I14:I15"), Unique:=False
    End Sub
    the only difference being one filters in-place.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •