View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default AutoFilter Criteria in VBA

Try the below

Sub Macro()

Dim dtStart As Date
Dim dtEnd As Date

dtStart = Workbooks("Other File.xls").Sheets("Sheet1").Range("A3")
dtEnd = Workbooks("Other File.xls").Sheets("Sheet1").Range("A9")

Selection.AutoFilter Field:=4, Criteria1:= _
"" & dtStart, Operator:=xlAnd
Selection.AutoFilter Field:=4, Criteria1:= _
"<=" & dtEnd, Operator:=xlAnd
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Hilvert Scheper" wrote:

Hi There,
Can Anyone help me out here Please,
I want to Filter a spreadsheet by Two criteria that refer to values in
another workbook: Greater than the Date in Cell A3 and Less than the Date in
Cell A9.
How on earth can I do this? I tried:

Selection.AutoFilter Field:=4, Criteria1:= _
"'[Other File.xls]Sheet1'!$A$3", _
Operator:=xlAnd
Selection.AutoFilter Field:=4, Criteria1:= _
"<='[Other File.xls]Sheet1'!$A$9", _
Operator:=xlAnd

and this doesn't work. The Filter is on but isn't showing Any entries...
I Really appreciate Your help!!
Rgds, Hilvert