AutoFilter Issue

R

R NG

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)
 
M

Mike Fogleman

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

R NG

Hello Mike,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top