Thread: Auto Filter
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Debra Dalgleish Debra Dalgleish is offline
external usenet poster
 
Posts: 2,979
Default Auto Filter

Try converting the dates to serial numbers. For example:

Selection.AutoFilter Field:=20, _
Criteria1:="=" & CLng(Txt_From), _
Operator:=xlAnd, Criteria2:="<=" & CLng(Txt_To)

Dim strStart As String
Dim strEnd As String
strStart = Application.InputBox("Start Date")
strEnd = Application.InputBox("End Date")

Selection.AutoFilter Field:=1, _
Criteria1:="=" & CLng(CDate(strStart)), Operator:=xlAnd, _
Criteria2:="<=" & CLng(CDate(strEnd))


Grisha Jose wrote:
I have used a Input Form which collects Date Range. In execute event I have
written following code

Selection.AutoFilter Field:=20,
Criteria1:="=" & Txt_From,
Operator:=xlAnd,
Criteria2:="<=" & Txt_To

I dont find any mistake in the above code. Data is entering in the custom
filter. But filter is not doing its work. Further Date format which I Enter
is DD/MM/YY.

I have applied filter on several other fileds and it works. But filter on
Date fields doesnot work.

Please send your valuable solution.

Regards

Grisha Jose



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html