+ Reply to Thread
Results 1 to 11 of 11

VBA autofiilter unprecised criterias

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    62

    VBA autofiilter unprecised criterias

    Hi all,

    Here is a challenge for most of you, I am not even sure it has a solution....

    Basically I am trying to filter an area with criterias that always change and I was wondering if there was a way to set up a criteria for all the names starting with "BNP P...."

    ActiveSheet.Range("$A$2:$AK$221960").AutoFilter Field:=8, Criteria1:= _
    "BNP..."

    This would be the equivalent of when you filter and you write what you are looking for where it automatically selects those things that start with the message you have written...

    Thank you and hopefully there is a genious out there capable of doing it,

  2. #2
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Pune
    MS-Off Ver
    Office 365 (Win 10)
    Posts
    489

    Re: VBA autofiilter unprecised criterias

    instead of your range, try to put this
    and select the cells where you want to run this macro
    ActiveSheet.Range(Selection.Address)

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: VBA autofiilter unprecised criterias

    ???? This does not solve this post.... This solves my other post

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

    Re: VBA autofiilter unprecised criterias

    Please Login or Register  to view this content.
    Currently, the criteria is fixed, i.e. BNP, but you can make it as a dynamic by linking the criteria to a cell, so when that cell changes, the criteria changes too.

  5. #5
    Registered User
    Join Date
    08-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: VBA autofiilter unprecised criterias

    This does not solve my problem as it is impossible for me to know the exact criteria because it changes all the time....

    Thank you anyway for trying...

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

    Re: VBA autofiilter unprecised criterias

    Where is the criteria stored?

  7. #7
    Registered User
    Join Date
    08-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: VBA autofiilter unprecised criterias

    Basically I am analysing some products that change every week but the code always starts with a similart thing; For example the code starts with "BNP..." and then something different. There istn really a fixed criteria, I just know how it starts...

    It the criteria would be anything that starts with "BNP...."
    And so on; tell me if I haven't been clear enough

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

    Re: VBA autofiilter unprecised criterias

    You can add wild card for (Criteria) BNP, but this also assumes the criterion always starts with "B" which is not probably the case.
    You may need a different approach.

  9. #9
    Registered User
    Join Date
    08-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: VBA autofiilter unprecised criterias

    Not sure what a wild card is and no; the criteria does not always start with B....

    Thinking of a different approach, should I try copy and pasting the column that I want to filter in a new column and then play around with the control replace? Do you think that could work? Any other ideas, suggestions?

    Thanks for trying mate

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

    Re: VBA autofiilter unprecised criterias

    May be use input box message to either ask for criteria, or use it to search for a particular word.
    A search code would be another option, instead of filtering.
    Wild card is "*". You add * as prefix, or suffix to criteria so that it filers all starting or ending with *

  11. #11
    Registered User
    Join Date
    08-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: VBA autofiilter unprecised criterias

    Tried the wildcard! It works quite well!

    Thank you so much, you saved me an awful amount of work.

    I'll mark this as solved and add to your reputation!

+ 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