Reputation: 185
Why doesn't this work? I only gives me the rows with the date 2020-06-08.
Today = "2020-06-09"
Yesterday = "2020-06-08"
sheets("eBS").Rows("8:" & Rows.Count).AutoFilter Field:=TCN, Criteria1:=">=" & Yesterday , _
Operator:=xlAnd, Criteria2:="<=" & Today
To get the rows with the date 2020-06-09 I have to use:
Today = "2020-06-09"
Yesterday = "2020-06-08"
sheets("eBS").Rows("8:" & Rows.Count).AutoFilter Field:=TCN, Criteria1:=">=" & Yesterday , _
Operator:=xlAnd, Criteria2:="<=" & Today + 1
Am I missing some logic here?
Upvotes: 0
Views: 35
Reputation: 50067
Your current logic will not work if your datetimes include a time portion.
"<=" & Today
will not include any date/times falling on today's date, but after 12:00 AM.
The easiest way to include them is to check if they are less than tomorrow (but not less than or equal to).
Upvotes: 2