+ Reply to Thread
Results 1 to 4 of 4

Autofilter problem with date format

  1. #1
    Registered User
    Join Date
    06-16-2020
    Location
    Colombia
    MS-Off Ver
    2016
    Posts
    11

    Autofilter problem with date format

    Hi everybody,

    I'm here looking for urgent help, I'm programming some Macros to automatizate a report for my job. In total I have 3 Macros, but the problem is with the second one.

    I start my code like this: (Macro1)

    Please Login or Register  to view this content.
    Then I change the format in the cells I'm going to filter by dates like this:

    Please Login or Register  to view this content.
    After that it continuous like this:

    Please Login or Register  to view this content.
    Until here there's no problem, (I checked manually the format of this cells while filter is running and it works. Format is DD/MM/YYYY) I know is weird but it works, so the problem is no here.

    The problem is here:

    Macro2:

    Please Login or Register  to view this content.
    And this filter doesn't find any info.

    When I check manually this filter, only works in the format "d-mmm-yyyy".

    So I stress because I've searched a lot and I've no searched nothing to solve it.


    I need both codes works under the same format and I don't know why de cell format change then the first code works good.


    If anybody can help me, I would appreciate it a lot.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Autofilter problem with date format

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). 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.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Autofilter problem with date format

    How are your dates stored in the spreadsheet? How are they handled by your variables FECHA and ANTERIOR? My first guess is that in one place the dates are real numbers/dates and in the other place they are text strings that only look like dates. I would be sure the dates are stored as dates (double data type as VBA would see them) in the spreadsheet, then make sure the FECHA and ANTERIOR are receiving the dates as numbers/doubles/longs so that the data type will be consistent between VBA and Excel.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Autofilter problem with date format

    Filtering Dates is most of the times tricky. Make sure the date criteria and the target date column have the same date format and it should work then without an issue.

    Macro1:

    Please Login or Register  to view this content.
    Macro2:

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

+ 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] date format problem and SUMIF() is not working date criteria
    By majidsiddique in forum Excel General
    Replies: 6
    Last Post: 03-25-2019, 12:19 AM
  2. [SOLVED] Date autofilter problem
    By Russet in forum Excel General
    Replies: 2
    Last Post: 07-08-2014, 04:49 PM
  3. [SOLVED] Dates in both date and text format mess up autofilter and sumifs in VBA
    By Maxdehaas in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-22-2014, 12:01 PM
  4. [SOLVED] Date autofilter problem - Excel 2013 version
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-21-2014, 12:10 AM
  5. Autofilter for date not recognising format
    By wazimu13 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-05-2013, 08:44 AM
  6. Advanced filter by date range, international date format problem
    By Senator685 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2013, 08:16 AM
  7. VBA Doesn't Understand My Date Format (Autofilter)
    By clattenburg cake in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2013, 01:41 PM

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