+ Reply to Thread
Results 1 to 18 of 18

Autofilter for a text that contains "Hit" (in an array)

  1. #1
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Autofilter for a text that contains "Hit" (in an array)

    Hi All,

    Im having an issue writing a macro to run an autofilter for multpile criteria, with one of those criteria defined as part of the text string contains Hit.
    What ive come up with so far is this:

    Please Login or Register  to view this content.
    Now when I record a macro for a custom filter for a text that contains Hit, I get this:

    Please Login or Register  to view this content.
    So when I replace
    Please Login or Register  to view this content.
    in the first macro with
    Please Login or Register  to view this content.
    from the second macro I no longer get any results for "Hit" or "Hit Face"
    What gives?

    Any help would be greatly appreciated, thanks!
    Attached Files Attached Files

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Autofilter for a text that contains "Hit" (in an array)

    You may not use wildcards with an array - it must be exact matches only.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Autofilter for a text that contains "Hit" (in an array)

    Why not use a second criteria for contains 'Hit'?
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array)

    Quote Originally Posted by Izandol View Post
    You may not use wildcards with an array - it must be exact matches only.
    Hello Izandol, thanks for the reply!
    That explains the mystery, definitely good to know.
    Do you know of a way around this?
    Thanks!

    Quote Originally Posted by Norie View Post
    Why not use a second criteria for contains 'Hit'?
    Hello Norie, thanks for the reply!
    Is that refferring to the first or second macro?
    Thanks!

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Autofilter for a text that contains "Hit" (in an array)

    It would be a combination of the two.

  6. #6
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array)

    Quote Originally Posted by Norie View Post
    It would be a combination of the two.
    Thank Norie, when I tried this:
    Please Login or Register  to view this content.
    the filter still didnt return any text strings that contains "Hit", only the exact matches. What am I doing wrong?

    Thanks!

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Autofilter for a text that contains "Hit" (in an array)

    You may not use array filter and regular filter on the same field (operator must be xlFilterValues so you may not use xlOr).

  8. #8
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array)

    Quote Originally Posted by Izandol View Post
    You may not use array filter and regular filter on the same field (operator must be xlFilterValues so you may not use xlOr).
    Please Login or Register  to view this content.
    Something along these lines maybe? This doesnt run but am I headed in the right direction? Thanks!

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Autofilter for a text that contains "Hit" (in an array)

    Pierce

    That won't work.

    Try filtering for the array then filtering for contains 'Hit'.

  10. #10
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Autofilter for a text that contains "Hit" (in an array)

    You may not achieve this with autofilter unless you provide all exact values, or make an additional formula column which can calculate your criteria. Perhaps an advanced filter will be better.

  11. #11
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array)

    Quote Originally Posted by Norie View Post
    Pierce

    That won't work.

    Try filtering for the array then filtering for contains 'Hit'.
    Norie,
    When I try this
    Please Login or Register  to view this content.
    none of the values in the array are displayed, but the "Hit" values are.
    When I do this:
    Please Login or Register  to view this content.
    none of the "Hit" values are displayed, but the array values are.

    This is frustrating

  12. #12
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array)

    Quote Originally Posted by Izandol View Post
    You may not achieve this with autofilter unless you provide all exact values, or make an additional formula column which can calculate your criteria. Perhaps an advanced filter will be better.
    Thanks Izandol, I'll be recording a macro using the advanced filter shortly to see what I can dissect.

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Autofilter for a text that contains "Hit" (in an array)

    What happens if you use the And operator?

    Please Login or Register  to view this content.

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Autofilter for a text that contains "Hit" (in an array)

    Pierce

    Apologies, Izandol is right.

    I could have sworn I'd previously applied similar filter criteria using AutoFilter.

  15. #15
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array)

    Quote Originally Posted by JOHN H. DAVIS View Post
    What happens if you use the And operator?
    Hi John, thanks for the reply!
    When I use this:
    Please Login or Register  to view this content.
    It filters out all values and displays nothing.
    Last edited by Pierce Quality; 01-15-2014 at 11:30 AM.

  16. #16
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array)

    Quote Originally Posted by Norie View Post
    Pierce

    Apologies, Izandol is right.

    I could have sworn I'd previously applied similar filter criteria using AutoFilter.
    Thanks Noire, I 'll be attempting to record the advanced filter shortly.

  17. #17
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array)

    Ok so after some research and then recording I came up with this:

    Please Login or Register  to view this content.
    I placed the criteria list in M1:M5 with the same header as the column I want filtered, I I used the wildcard *Hit* along with the other values.

    It appears to be working initally, but i'll be testing it for a while yet.
    Attached Files Attached Files

  18. #18
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Autofilter for a text that contains "Hit" (in an array) update

    So I ended up using the code for the advanced filter and everything is working as planned.
    Marking this as solved, thanks!

+ 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. Date format of just "st" "nd" "rd" and "th" with text included
    By notrandom in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-10-2013, 05:45 PM
  2. AutoFilter: Setting Criteria1 to an Array for "Any of these words" type filtering
    By sheldonbeswift in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-16-2013, 10:57 AM
  3. How can i copy value from "HTMLText"(EMBED("Forms.HTML:Text","")),using Macro
    By andrewyang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2010, 12:47 AM
  4. Replies: 6
    Last Post: 05-09-2010, 05:58 PM
  5. [SOLVED] If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ...
    By Maria J-son in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2006, 08:25 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