Posted to microsoft.public.excel.programming
|
|
AutoFilter Criteria in VBA
hmm .... UK date format worked fine for me.
"Ron de Bruin" wrote in message
...
Important: Use always the US mm/dd/yyyy format if you filter Dates.
Note: You only have the use the mm/dd/yyyy format in the code, no problem
if the format in the worksheet is different.
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
"Patrick Molloy" wrote in message
...
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
|