+ Reply to Thread
Results 1 to 5 of 5

Thread: VB function to check for dates

  1. #1
    Registered User
    Join Date
    09-21-2011
    Location
    florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    VB function to check for dates

    Folks,
    Thanks to 0EGO from the forum to get me this code working fine, however,If you see above, Cell reference "D2" checks for a date value from a pop up calendar I have on that cell. Currently, it filters only for that selected value. However, I need it to display all values "LESS" than the selected date value. Please advise,
    Example: If the user selects 1st February 2012 on "D2", the filter should display all rows with date BEFORE 1st February 2012, currently it gives all rows with the date as 1st February 2012.

    Thanks for your help

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target = Range("D2") Then
           Range("A13").CurrentRegion.AdvancedFilter _
               Action:=xlFilterInPlace, _
               CriteriaRange:=Range("D1:D2")
       End If
    End Sub
    Last edited by ame; 02-09-2012 at 02:20 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-20-2011
    Location
    mysore
    MS-Off Ver
    Excel 2003
    Posts
    423

    Re: VB function to check for dates

    In D2 cell enter the following

    ="<="&DATE(2012,2,1)

  3. #3
    Registered User
    Join Date
    09-21-2011
    Location
    florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: VB function to check for dates

    Hello KVS,

    I seem to miss something, Please look at attached,
    Cell D3 has the pop up calendar,
    Cell D2 has the changes you mentioned,
    The VB function makes the filter work based on the change to cell D2 but it does not give the required output.
    Example, If the user selects 02/09/2012 (todays date) from the calendar (Cell D3), the table should list all the rows as the values in column I are less than todays date.

    Thanks for your help

  4. #4
    Registered User
    Join Date
    09-21-2011
    Location
    florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: VB function to check for dates

    Works Great..Thank You solved

  5. #5
    Registered User
    Join Date
    09-21-2011
    Location
    florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    (Solved) VB function to check for dates

    this issue was resolved

+ 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.2.0