Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AutoFilter Issue

Hello all,

I have a table with the second column being a date field. I use the macro
recorder to record my autofilter action:
1. Select the headings (A4:E4) of the table;
2. Apply autofiltering;
3. On the second column (the date field), set the criteria to be "on or
after 01.08.2009"
and came up with the following code:

Range("A4:E4").Select
Selection.AutoFilter
ActiveSheet.Range("$A$4:$E$9").AutoFilter Field:=2, Criteria1:= _
"=01.08.2009", Operator:=xlAnd

Things work fine (i.e. only records on or after 01.08.2009 are displayed)
while I was recording, but when I "unfilter" and then run the above code,
all records are filtered out. Nothing left.

This same issue occurs while using either Excel XP or Excel 07 in
compatibility mode.
Then I recorded another macro for autofiltering a text field, the macro
works fine, so it seems the problem has something to do with the date. I
tried tinkering with the code somewhat, but no luck. What can I do now?

Suggestions are most welcome. (I use Win XP)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default AutoFilter Issue

Remember VB only speaks English, try changing the date format in your
criteria,
Critria1:="=08/01/2009" 'Aug 1, 2009
leave the Operator off

Mike F
"R NG" wrote in message
...
Hello all,

I have a table with the second column being a date field. I use the macro
recorder to record my autofilter action:
1. Select the headings (A4:E4) of the table;
2. Apply autofiltering;
3. On the second column (the date field), set the criteria to be "on or
after 01.08.2009"
and came up with the following code:

Range("A4:E4").Select
Selection.AutoFilter
ActiveSheet.Range("$A$4:$E$9").AutoFilter Field:=2, Criteria1:= _
"=01.08.2009", Operator:=xlAnd

Things work fine (i.e. only records on or after 01.08.2009 are displayed)
while I was recording, but when I "unfilter" and then run the above code,
all records are filtered out. Nothing left.

This same issue occurs while using either Excel XP or Excel 07 in
compatibility mode.
Then I recorded another macro for autofiltering a text field, the macro
works fine, so it seems the problem has something to do with the date. I
tried tinkering with the code somewhat, but no luck. What can I do now?

Suggestions are most welcome. (I use Win XP)




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default AutoFilter Issue

Hello Mike,

That works! Thank you very much!
The macro recorder is not so dependable it seems.


"Mike Fogleman" bl...
Remember VB only speaks English, try changing the date format in your
criteria,
Critria1:="=08/01/2009" 'Aug 1, 2009
leave the Operator off

Mike F
"R NG" wrote in message
...
Hello all,

I have a table with the second column being a date field. I use the macro
recorder to record my autofilter action:
1. Select the headings (A4:E4) of the table;
2. Apply autofiltering;
3. On the second column (the date field), set the criteria to be "on
or after 01.08.2009"
and came up with the following code:

Range("A4:E4").Select
Selection.AutoFilter
ActiveSheet.Range("$A$4:$E$9").AutoFilter Field:=2, Criteria1:= _
"=01.08.2009", Operator:=xlAnd

Things work fine (i.e. only records on or after 01.08.2009 are displayed)
while I was recording, but when I "unfilter" and then run the above code,
all records are filtered out. Nothing left.

This same issue occurs while using either Excel XP or Excel 07 in
compatibility mode.
Then I recorded another macro for autofiltering a text field, the macro
works fine, so it seems the problem has something to do with the date. I
tried tinkering with the code somewhat, but no luck. What can I do now?

Suggestions are most welcome. (I use Win XP)






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
Issue with Autofilter and Pictures J_Mori Excel Discussion (Misc queries) 3 April 20th 07 09:22 PM
Autofilter Issue PWS Excel Worksheet Functions 3 April 18th 07 04:23 PM


All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"