+ Reply to Thread
Results 1 to 17 of 17

Advanced Filter "<=Date" does not work?

  1. #1
    Registered User
    Join Date
    03-30-2011
    Location
    Swansea
    MS-Off Ver
    Excel 2007
    Posts
    72

    Advanced Filter "<=Date" does not work?

    I just can not get this code to work.

    I want it to look for data equal to a user inputted Account Number and Start and End Date. The input bit seems to work, the rest doesn't.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by MAButler; 04-04-2011 at 02:41 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: Advanced Filter "<=Date" does not work?

    One problem I see is your assignment of values to X1,Y1,Z1. Avanced Filter requires that the header of the criteria match the source headers... I don't think you do. For example youi've defined Your account column as "AccountColumn As Integer = 1 " but when you place your head in X1 you're getting your value of column number from a variable called "Account" ... what value does that have ?

    MY ADVICE to you is to first make sure you are setting up your Advanced Critera Correctly ... in other words halt your code at the line ' Apply Advanced Filter and look at your sheet... is the criteria area set up with the correct information ?

    How to halt code.... before running macro goto VBEditor and click on the code modules border on the line you want code to stop ...if done correctly a dot should appear on the module border and code line should change in color.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by nimrod; 04-03-2011 at 07:14 PM.

  3. #3
    Registered User
    Join Date
    03-30-2011
    Location
    Swansea
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Advanced Filter "<=Date" does not work?

    I have made the following changes, still no data.....
    I have stopped at the point just before the delete line, and then using the sheet as it is I have manualy done the Advanced Filter and the data is sorted........
    I have recorded a Macro and compaired it looks the same...... what is the problem....

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: Advanced Filter "<=Date" does not work?

    Hi

    You need to amend your code as follows.
    You are not using the correct criteria to pick up the filter headings, and you have not given any headings for the columns you want to extract

    Please Login or Register  to view this content.
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Advanced Filter "<=Date" does not work?

    Keep it simple:

    Please Login or Register  to view this content.



  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,288

    Re: Advanced Filter "<=Date" does not work?

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

    Read this to understand why we ask you to do this
    Remember what the dormouse said
    Feed your head

  7. #7
    Registered User
    Join Date
    03-30-2011
    Location
    Swansea
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Advanced Filter "<=Date" does not work?

    Last edited by romperstomper; 04-04-2011 at 08:00 AM.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,288

    Re: Advanced Filter "<=Date" does not work?

    Try:
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: Advanced Filter "<=Date" does not work?

    Hi MAButler:
    Upload a sample so we can take a look at it.

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Advanced Filter "<=Date" does not work?

    Hi MAButler

    Change these two lines of code
    Please Login or Register  to view this content.
    It worked for me.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  11. #11
    Registered User
    Join Date
    03-30-2011
    Location
    Swansea
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Advanced Filter "<=Date" does not work?

    Thanks for all the replies.......

    I have tried them all:-

    SNB = Took data over but only matching Account and Start date....... No match for the End Date and no new workbook.

    romperstomper = Error code 'TYPE MISMATCH'

    Nimrod = I have attached the file.....
    Attached Files Attached Files

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Advanced Filter "<=Date" does not work?

    Hi MAButler
    Try the attached...notice, I HAVE changed some of your code
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    03-30-2011
    Location
    Swansea
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Advanced Filter "<=Date" does not work?

    Thanks "jaslake", that worked........

    Simple when you know how.......

    Mike

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Advanced Filter "<=Date" does not work?

    Hi Mike...look at your dates...select a cell. See what the cell contains? Look at the Formula Bar...see what it contains?

  15. #15
    Registered User
    Join Date
    03-30-2011
    Location
    Swansea
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Advanced Filter "<=Date" does not work?

    Thanks for your help........ But you have lost me with the attached quote....


    Quote Originally Posted by jaslake View Post
    Hi Mike...look at your dates...select a cell. See what the cell contains? Look at the Formula Bar...see what it contains?

  16. #16
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Advanced Filter "<=Date" does not work?

    Hi Mike

    Select cell B12...in the cell, it says 07/04/2010
    In the Formula Bar, it says 4/7/2010 (at least on my system). That's why the code worked.

  17. #17
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,288

    Re: Advanced Filter "<=Date" does not work?

    Quote Originally Posted by MAButler View Post
    romperstomper = Error code 'TYPE MISMATCH'
    Yes, I overlooked the fact your 'date' variables are actually strings, so you'd need:
    Please Login or Register  to view this content.

+ 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