+ Reply to Thread
Results 1 to 3 of 3

Using macro to filter worksheet using dates

  1. #1
    Registered User
    Join Date
    06-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Using macro to filter worksheet using dates

    Hi everyone,

    I'm trying to write a little macro (that runs from a ComboBox) which filters a worksheet by several criteria, one of which is the date in column D is between to values.
    These date values are stored on the worksheet in cells B2 and C2 with value 1June11 and 31May12 respectively.

    PART 1
    The macro does filter, and if i remove the date part (in bold) works perfectly.
    However when i filter with the date, no records remain visible. Investigating what it has filtered by, the filter has dates in (which are wrong - please see second part of question!) but no records show. if i click ok after checking the data suddenly 12 records appear.
    Any ideas whats happening?


    Please Login or Register  to view this content.

    PART 2
    YrStart should equal 1June2011 and YrEnd should equal 31May2012
    If i watch the values, this is what they show they contain.
    HOwever, when i run the code above the filter criteria it picks up is 6January2012 to 31May2012
    Any ideas how to solve?


    Thanks guys - heres to praying you can help!!

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Using macro to filter worksheet using dates

    Apparently you have to search for the date in it's standard form. See this link and scroll to bottom paragraph.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    06-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Using macro to filter worksheet using dates

    Thanks David. Your hint didn't solve the problem but did make me think about it a different way.

    For anyone out there who hits a similar problem to me, this is the code i ended up with, and it does work!

    Please Login or Register  to view this content.

    It's probably longwinded - there must be an easier way - but does it matter when this works too?

    Claire

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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