Consulting

Results 1 to 2 of 2

Thread: Filter on prior date

  1. #1
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location

    Filter on prior date

    Hi, looking at filtering on the previous date, the following says all the right dates, however the filter returns nothing. Please see below

    Today (StartDate) is the 21st and EndDate is the 19th

    Any help as usual will be greatly rec'd

    Sub Macro1()Dim StartDate As Date
    Dim EndDate As Date
    StartDate = Date
    
    EndDate = (Date - 2)
    
    Range("A1:D1").Select
        Selection.AutoFilter
        ActiveSheet.Range("$A$1:$E$1").AutoFilter Field:=4, Operator:= _
            xlFilterValues, Criteria2:=EndDate
              
    End Sub
    Excel spreadsheet before filter


    before filter.PNG

    spreadsheet after applying code


    filter
    filter.jpg

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    ???

        With Range("A1").CurrentRegion
            .AutoFilter
            .AutoFilter 4, ">=" & EndDate, xlAnd, "<=" & EndDate
        End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •