• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Dates filter not working in VBA

chriscorpion786

New Member
Hello ALL,

I have a macro that filters dates by month and year based on cell values. I have dates that range from the year 2020 till year 2030.
Now the strange part is that all years filter properly except for any dates that lie within the year 2030
I have the below code and could'nt find a solution as to why 2030 dates are not filtering.

>>> use code - tags <<<
Code:
Dim startdt As Range
Dim enddt As Range

Set startdt = ThisWorkbook.Sheets("Controls").Range("J2")' e.g format is 01-05-2030
Set enddt = ThisWorkbook.Sheets("Controls").Range("L2")e.g format is 31-05-2030

ThisWorkbook.Sheets("Tasks").Range("A1").AutoFilter Field:=1, Criteria1:=">=" & startdt, Operator:=xlAnd, Criteria2:="<" & enddt
 
Last edited by a moderator:
See
Code:
ThisWorkbook.Sheets("Tasks").Range("A1").AutoFilter Field:=1, Criteria1:=">=" & startdt * 1, Operator:=xlAnd, Criteria2:="<" & enddt * 1
 
Back
Top