MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Still need help with auto filter

Posted by Tyler Hart on August 23, 2001 6:33 AM

This is what I have and need a macro to do this:
A1 = Any start date inputed by operator
A2 = Any stop date inputed by operator

Then filter column "B" with the criteria:
>=Range("a1") <=Range("a2")


Posted by Barrie Davidson on August 23, 2001 11:45 AM

The following macro will filter a range named "Data_Table" where the first field in the table is >=A1 and <=A2.

Sub Filter_Macro()
' Macro written by Barrie Davidson
Dim LowerCriteria As String
Dim UpperCriteria As String

LowerCriteria = ">=" & Format(Range("A1").Value, "mmm dd, yyyy")
UpperCriteria = "<=" & Format(Range("A2").Value, "mmm dd, yyyy")
Selection.AutoFilter Field:=1, Criteria1:=LowerCriteria, Operator:= _
xlAnd, Criteria2:=UpperCriteria
End Sub

Hope this is what you need.