+ Reply to Thread
Results 1 to 4 of 4

AutoFilter a column on 3 criteria using Arrays does not work

  1. #1
    Registered User
    Join Date
    05-13-2017
    Location
    pune
    MS-Off Ver
    2010
    Posts
    8

    AutoFilter a column on 3 criteria using Arrays does not work

    Hi All,

    My requirement is to filter a column based on 3 criteria, I found on web that easiest way to do it will be using Array, but is seems that when I pass the values to the Arrays in asterix *SearchTerm*, the filter returns blanks.

    This is my source Data:

    SourceData.PNG

    When I use Macro 1 as below, it filters correctly as expected.

    Macro1Works.PNG

    But When I pass the values enclosed in asterix, it does not filter and gets blank.

    Macro1DoesNotWorks.PNG

    This is the result when the values are passed as "*Green*" and so on.

    result.PNG


    Could you please help.
    Last edited by ritesh.sharma25; 02-12-2018 at 11:04 AM.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: AutoFilter a column on 3 criteria using Arrays does not work

    Hi ritesh.sharma25,

    The Autofilter xlFilterValues operator does not allow wildcards to the best of my knowledge. If you have only have two 'or' items, the xlOr (or xlAnd) operator can be used with wildcards. For 3 or more 'or' items with wildcards, you have to identify all the items in the list that match your criteria. This can be done with 'Scripting Dictionary' code.

    See the following link for examples: https://stackoverflow.com/questions/...22944#34822944

    Lewis

  3. #3
    Registered User
    Join Date
    05-13-2017
    Location
    pune
    MS-Off Ver
    2010
    Posts
    8

    Re: AutoFilter a column on 3 criteria using Arrays does not work

    Thanks Lewis.

    The method you mentioned, seems a bit complicated to me as I am not that good with macro, still will give it a try

    Regards,
    RVS

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: AutoFilter a column on 3 criteria using Arrays does not work

    Thanks for the rep points.

    It's not that difficult, it only looks that way. It's a two part process:

    a. Create a 'Scripting Dictionary' that contains a list of all the Unique values in your 'AutoFilter' Column. A 'Scripting Dictionary' is a built in Excel item that has many uses, and is very good at creating a list of unique items. For reference see https://www.experts-exchange.com/art...ss-in-VBA.html
    http://www.snb-vba.eu/VBA_Dictionary_en.html

    b. Create an array of items from the Dictionary that match your search criteria.

    If you need additional help upload a sample workbook, and indicate what you want to do.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

+ 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. macro to autofilter 2 criteria in same column
    By chubbychub in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2016, 04:39 AM
  2. multiple look up arrays to sum column based on various criteria
    By deanusa in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-14-2016, 04:11 AM
  3. Replies: 11
    Last Post: 02-16-2016, 11:06 PM
  4. VBA autofilter on computed table column does not work?
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-08-2016, 11:13 PM
  5. [SOLVED] SUM data with multiple ranges and criteria, I don't think arrays will work
    By Joachim17 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-26-2015, 05:30 PM
  6. Autofilter for more than 2 criteria in one column using VBA
    By JohnnyBGood in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2011, 11:19 AM
  7. [SOLVED] Why won't it work when I use VBA to set autofilter criteria to ce.
    By biggy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-25-2005, 11:06 AM

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.6.0 RC 1