ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   filter on date (https://www.excelbanter.com/excel-programming/398581-filter-date.html)

dan

filter on date
 
I am trying to filter on a date.

Range("C8").AutoFilter Field:=3, Criteria1:="=10/08/2007 00:00",
Operator :=xlAnd, Criteria2:="<=13/08/2007 24:00"

( I got that from recoding a macro)

but that does not work from the code - some filtering is done but I get a
blank table (when I was reording the macro I was getting the correct results).

Any Idea? thanks

Dan



dan

filter on date
 
I have found the reason (but still do not know how to solve it)

For some reason excel convert all my date to american format so 10/08/2007
become 008/10/2007 and therefor there is no result.

All my setting are UK settings?

Any idea

"Dan" wrote:

I am trying to filter on a date.

Range("C8").AutoFilter Field:=3, Criteria1:="=10/08/2007 00:00",
Operator :=xlAnd, Criteria2:="<=13/08/2007 24:00"

( I got that from recoding a macro)

but that does not work from the code - some filtering is done but I get a
blank table (when I was reording the macro I was getting the correct results).

Any Idea? thanks

Dan



Bob Phillips

filter on date
 
Darn US dates <g

Dim date1_value As Date
Dim date2_value As Date


Sheets("Detail").Select
date1_value = DateValue("10-Aug-2007")
date2_value = DateValue("13-Aug-2007")
Range("C8").AutoFilter Field:=1, _
Criteria1:="=" & Str(CDbl(date1_value)), _
Operator:=xlAnd, _
Criteria2:="<=" & Str(CDbl(date2_value))


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Dan" wrote in message
...
I have found the reason (but still do not know how to solve it)

For some reason excel convert all my date to american format so 10/08/2007
become 008/10/2007 and therefor there is no result.

All my setting are UK settings?

Any idea

"Dan" wrote:

I am trying to filter on a date.

Range("C8").AutoFilter Field:=3, Criteria1:="=10/08/2007 00:00",
Operator :=xlAnd, Criteria2:="<=13/08/2007 24:00"

( I got that from recoding a macro)

but that does not work from the code - some filtering is done but I get a
blank table (when I was reording the macro I was getting the correct
results).

Any Idea? thanks

Dan






All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com