+ Reply to Thread
Results 1 to 2 of 2

local settings affect autofilter dates with VBA

  1. #1
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    local settings affect autofilter dates with VBA

    This is more for the benefit of my British & European chums:

    When providing a date to autofilter via VBA you must put it in American order. This I think, is because of the way Excel converts the date to a string to put it into the filter 'behind the scenes' (hence not localised properly).

    This wasn't working:
    Please Login or Register  to view this content.
    Although the autofilter created looked like it ought to work, indeed recreating the exact same filter manually did work. I found that as the date was > 12 the month & date were effectively coerced into the right place. When I changed the maths to return a day of month less than 12 I saw that the day & month swapped in the custom filter created.
    This does work (showing my thought process):
    Please Login or Register  to view this content.
    which can be tidied up:
    Please Login or Register  to view this content.
    HTH
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: local settings affect autofilter dates with VBA

    Try converting the date to a Long

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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