+ Reply to Thread
Results 1 to 2 of 2

Date criteria in autofilter

  1. #1
    Registered User
    Join Date
    02-21-2012
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    1

    Date criteria in autofilter

    Hi buds,
    this problem has been driving me crazy, i have a range of data in excel sheets, and one of the column containes DATE located in field 1, and i 'm writing a macro to display the results based on date criteria. I've been very careful in this DATE things, and i use calendar control to input the date value for the DATE field, so it's safe to say that the date values are correct. Now i use the srcripts below to display data with date criteria, but i keep getting blank page instead of the results that i wanted.
    Sub cmd_inventory ()
    txtDate.text = Calendar1.value
    With Sheets("inventory")
    .AutoFilterMode = False
    .Range("inventory").AutoFilter
    .Range("inventory").AutoFilter field:=1, Criteria1:= txtDate.text



    End With

    End Sub

    Thank you

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Date criteria in autofilter

    use criteria as
    cdate(<actual date>)


    I am giving you a trivial example
    suppose data is like form A1

    hdng1 hdng2
    1/1/2012 1
    1/2/2012 2
    1/3/2012 3
    1/5/2012 4
    1/5/2012 5
    1/6/2012 6
    1/2/2012 7
    1/8/2012 8
    1/9/2012 9
    1/2/2012 10

    now try this macro

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    use this idea to solve your problem
    I am not an expert. better solutions may be available
    [email protected]

+ 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