Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel 2007 autofilter change to 2003 autofilter functionality? | Excel Discussion (Misc queries) | |||
2007 excel autofilter back to 2003 autofilter? | Excel Discussion (Misc queries) | |||
2007 excel autofilter change back to 2003 autofilter? | Excel Discussion (Misc queries) | |||
Issue with Autofilter and Pictures | Excel Discussion (Misc queries) | |||
Autofilter Issue | Excel Worksheet Functions |