View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Girish Girish is offline
external usenet poster
 
Posts: 3
Default Why isn't this macro giving me proper results?

Thanks a ton guys, both your suggestions are working. great.
--
Girish Bhatta V.
Bangalore, India


"Tushar Mehta" wrote:

In article ,
says...
Good Morning,

Can someone please look in and spot the problem. Basixcally what I'm trying
to do here is to filter a range of dates.

But what actually happens when I run this code is that the Excel filters for
"From1" and "To1" literally (as text/string) and not for values stored in
these range variables.

Solution Please.....

Sub Macro3()
Dim From1, To1 As Range
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
Set From1 = Worksheets("Individual").Range("E45")
Set To1 = Worksheets("Individual").Range("K45")
Sheets("Quality Check Log").Select
Range("A3").Select
Selection.AutoFilter Field:=1, Criteria1:="=From1", Operator:=xlAnd,
Criteria2:="<=To1"
End Sub



Untested suggestion.
Selection.AutoFilter Field:=1, Criteria1:="=" & From1.Value, _
Operator:=xlAnd, Criteria2:="<=" & To1.Value

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions