PDA

View Full Version : [SOLVED] Filter on prior date



heathb
07-21-2017, 07:10 AM
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


19834

spreadsheet after applying code












19833



filter
19835

mana
07-22-2017, 03:40 AM
???


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