+ Reply to Thread
Results 1 to 6 of 6

Criteria range for advance filter not working.

  1. #1
    Registered User
    Join Date
    05-08-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    81

    Criteria range for advance filter not working.

    Heya,

    I'm trying to copy data thru VBA. Specifically, I want to copy only those rows whose corresponding cell in the date column (column "A") has the month text that I'm looking for in a specific cell range - the Criteria Range. In this case, it'd be cell "Z1". If "Z1" says April, then only copy those rows whose date column contained a corresponding date containing the string "April". The macro is run from a macro file with a button and a field where the month name is entered. The copying is done from a separate file.

    Right now, the copying seems to be working fine but regardless of what I type in Z1 as the Criteria Range, I still get ALL rows. I'm not sure what the issue is.

    Here is the code. I'm trying to solve something that was left over from a colleague who left, and they didn't comment, nor apply proper naming conventions but I still hope it will be readable. I will definitely correct this as soon as this issue is resolved.

    Please Login or Register  to view this content.
    Any help would be appreciated. Thanks!
    Last edited by noname91; 11-20-2020 at 01:42 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Criteria range for advance filter not working.

    Hi

    Please Login or Register  to view this content.
    The criteria range should have at least 2 cells, like Z1:Z2 with name of the field in Z1 and the criterion in Z2.

  3. #3
    Registered User
    Join Date
    05-08-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    81

    Re: Criteria range for advance filter not working.

    Thanks for the reply lecxe!

    I see. I've made the changes to the code, but unfortunately I'm still getting all rows copied instead of only the rows that should contain the month in question. I'm now using rows Y1:Y2 where Y1 is "Date" and Y2 is the month text.

    Here is the updated code:

    Please Login or Register  to view this content.
    Last edited by noname91; 11-20-2020 at 03:13 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Criteria range for advance filter not working.

    Hi

    Quote Originally Posted by noname91 View Post
    Please Login or Register  to view this content.
    Seems perfectly OK to me.

    I can only think that maybe the criterion in Y2 is not correct.

    It would help if you'd post a workbook with a small sample. This would allow us to test your code.

  5. #5
    Registered User
    Join Date
    05-08-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    81

    Re: Criteria range for advance filter not working.

    Ah, I see. Wasn't sure if it was an issue with the syntax or something else on my end. In any case, I redid the whole thing from scratch with a somewhat different approach and the Criteria Range looks like its working as expected now.

    Not sure what the issue was, might trouble shoot on my end later on.

    Thanks for the clarifications!

  6. #6
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Criteria range for advance filter not working.

    You're welcome.

+ 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. [SOLVED] Advance Filter Not working Via VBA
    By mayoorsubbu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-16-2017, 08:22 AM
  2. [SOLVED] Advance filter dynamic criteria range
    By Pierce Quality in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2015, 12:32 PM
  3. [SOLVED] Advance Filter Criteria
    By Dave Peterson in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 07:05 AM
  4. Advance Filter Criteria
    By Dave Peterson in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 06:05 AM
  5. [SOLVED] Advance Filter Criteria
    By Dave Peterson in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 04:05 AM
  6. [SOLVED] Advance Filter Criteria
    By Jordan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  7. Advance Filter Criteria
    By Jordan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

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