+ Reply to Thread
Results 1 to 7 of 7

How to use autofilter with an array

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    37

    How to use autofilter with an array

    Hi,

    I am trying to filter a list based on certain names that the list can include. My code isn't working and I can't figure out why. The tricky thing is I can't just list all of the names I want to include because there can be several different ones that are spelled slightly different but all mean the same thing, so I need to say "can contain" specific words. I have no problem doing this with 2 names, but when I try to include several (like 8 or 9) excel flips out. The code is below. Is there something wrong with it or is there a way around it? Thank you for your help!

    Please Login or Register  to view this content.

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

    Re: How to use autofilter with an array

    My guess is the array might work with exact match only, no like *.

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: How to use autofilter with an array

    Angelfish13,

    Remove all the equal signs, they are unnecessary and confusing the compiler. [EDIT] (This next part is wrong, I apologize) [/EDIT]: The wildcards are fine, you can keep those.

    So wildcards will only work in arrays of 2 or fewer elements, sorry for the confusion. Could probably get the data you want a different way though
    Last edited by tigeravatar; 07-03-2013 at 06:44 PM. Reason: added edit
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: How to use autofilter with an array

    Maybe give something like this a try
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-17-2013
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: How to use autofilter with an array

    Hi everyone,

    Thank you so much for the replies. Unfortunately, Tigeravatar, the code did not work I am not sure why. I appreciate the help any way!

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

    Re: How to use autofilter with an array

    "I have no problem doing this with 2 names".
    This is also the case with xlor and AND . xlAnd operators. They can handle two options only.
    The other option would be to create layers of filter for pairs, but the code may look cumbersome.

  7. #7
    Registered User
    Join Date
    06-17-2013
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: How to use autofilter with an array

    I know I have realized this now I found a workaround solution to my problem (just typed in every possible name I could think of that could somehow come up in an array). its just super messy and will probably take forever to run. Better than nothing though!

+ 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