Excel VBA Code Date Filter between two dates

Closed
Bhaskar - Apr 27, 2010 at 12:03 PM
 Basit - May 17, 2010 at 06:46 AM
I want to filter data between "15 apr 2010" and "26 apr 2010" . All Dates are stored in column B. The below code is generated by excel macro recorder but despite having dates between the specified range nothing is showing when I run the macro. Dates are stored in "dd/mm/yyyy" format
Please help me.

Thanx

ActiveSheet.Range("$B$5:$O$289").AutoFilter Field:=2, Criteria1:= _
">=15/04/2010", Operator:=xlAnd, Criteria2:="<=26/04/2010"
Related:

1 response

in case of date store the range of date in variables fromdate and todate. Input values in Variables whether through excel cell or inputmsg or hard code it. Try this code

ActiveSheet.Range("$B$5:$O$289").AutoFilter Field:=2, Criteria1:= _
">=" & fromdate, Operator:=xlAnd, Criteria2:="<=" & todate

hope this works
7