View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default AutoFilter Criteria in VBA

if you'd like to send me two excel workbooks , i'll see what i can do

"Hilvert Scheper" wrote in
message ...
Dear Patrick,
Also to You a Huge Thanks for Your interference, I have tried Your
suggestion
However Whetever I try, Nothing seems to work.
I just give up for now, can't afford to spend more time on this than I
already have, pretty close to a full day and not getting anywhere.

Many Thanks, and SORRY!
Hilvert


"Patrick Molloy" wrote:

when using autofilter from the sheet data, you'll see dates in the
dropdown
for values.
In code, when you select a date, you'll see the excel internal number.
like
40008 for today

so in code you need to convert, eg

Option Explicit
Sub setFilter()
Dim sFilter As String
sFilter = "=" &
Format$(Workbooks("Book2").Worksheets(1).Range("C3 "),
"dd/mm/yyyy")
Selection.AutoFilter
Selection.AutoFilter Field:=6, Criteria1:=sFilter, Operator:=xlAnd
End Sub

NOTICE I used "=" since there's no operator equivalent.



"Hilvert Scheper" wrote in
message ...
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