+ Reply to Thread
Results 1 to 4 of 4

AutoFilter Multiple Criteria Array

  1. #1
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299

    AutoFilter Multiple Criteria Array

    The attached sheet contains the following code I wrote. I'm trying to set the autofilter to display only the values I load into my array (even numbers 2 - 12 on column D). The code does not debug, but it doesn't work? The autofilter gets turned on but the criteria doesn't. If i remove the "Operator:=xlFilterValues" then the last value allocated to my array, which is "12" does get set. Not sure what is wrong.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by erock24; 03-29-2011 at 01:27 PM.

  2. #2
    Registered User
    Join Date
    04-14-2010
    Location
    NZ
    MS-Off Ver
    2007,2010
    Posts
    86

    Re: AutoFilter Multiple Criteria Array

    I'm not certain why..
    It seems to be that your array needs to be a String datatype rather than variant.

    Perhaps someone with more knowlege on these functions could explain..

  3. #3
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299

    Re: AutoFilter Multiple Criteria Array

    I got it!! I changed the array variable to a string and in the autofilter code I edited to this:
    Please Login or Register  to view this content.
    I also fill the array in a separate function routine now. Here is whole code. which works.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-06-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: AutoFilter Multiple Criteria Array

    Hi erock24,

    I'm trying something similar with a macro but I'm not able to figure out why the criteria is not returning the right results. Here is my code:

    Range(ActiveCell.CurrentRegion.Address).AutoFilter Field:=ActiveCell.Column, Criteria1:=Array( _
    "HANNA*", "MARK*", "LUTHER*")


    So, basically I need my filter to do a "begins with" filter on the mentioned names. But the macro seems to return filter results only based on the last name mentioned in the Array and ignores the rest. Any idea how I can fix this, or if I need to change my code completely? Please help!

    Thanks,
    Q.

+ 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