+ Reply to Thread
Results 1 to 4 of 4

AutoFilter with 3 or More Criteria

  1. #1
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    AutoFilter with 3 or More Criteria

    Good afternoon,

    I am looking to create an AutoFilter that looks for multiple different beginning combinations. Please see below for code:

    ActiveSheet.Range(Cells(1, 1), Cells(LastRow, LastCol)).AutoFilter Field:=13, Criteria1:=Array("56*", "57*", "59*", "62*", "67*"), Operator:=xlFilterValues

    When I use the first 2 criteria the code seems to work correctly, however, when adding any more the filters returns with no results which is not correct. When I record a macro and manually select the records to include, it lists a huge array of criteria and runs properly. Is there a way to add a begins with property to the code Excel generates when recording a macro?

    Thanks.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: AutoFilter with 3 or More Criteria

    Asterisk (*) works with at most two choices. It is the same as "OR" and "AND" filter options.

  3. #3
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Re: AutoFilter with 3 or More Criteria

    Thanks for the reply. So it seems the best way to go about doing this is to do a loop and filter for 2 criteria at a time and copy and paste results? Does that seem right?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: AutoFilter with 3 or More Criteria

    Yes,
    It depends what do you want to do once you have filtered cells. If you are going to copy them to some where or delete them, You can filter 2 at a time, remove the filter, apply the next 2 again and remove filter and so on. It is the same as switching on and off the filter button.

+ 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. Replies: 4
    Last Post: 03-16-2013, 08:33 AM
  2. [SOLVED] Autofilter with multiple criteria - how to ignore blank criteria
    By MOONDRIFT47 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-31-2012, 12:20 PM
  3. Replies: 2
    Last Post: 07-06-2012, 11:42 AM
  4. autofilter macro: goto the next criteria down until certain criteria is reached
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-27-2008, 04:31 PM
  5. [SOLVED] Autofilter criteria not yet known
    By JeffMelton in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2006, 03:20 AM

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