Strange behaviour of autofilter

L

lars.knutus

HI everyone,
I happen to encounter a - in my eyes - really strange behaviour of
excel in reaction to a macro.

The sub in question should set an auto filter on a column to show all
entries with a late smaller or equal to today. And in case the
autofilter is already set deactivate it upon execution.

However when I run the sub no rows at all are displayed even not those
which should be. However when I look at the autofilter settings,
change nothing and just press ok. Then it works as it should. So I
wonder what's up here? I'd really appreciate input on this as I just
ran out of ideas.

Here is the code in question

Sub ShowCurrentTasks()

If (ActiveSheet.AutoFilter.Filters(4).On) Then
Selection.AutoFilter Field:=4
Else
Selection.AutoFilter Field:=4, Criteria1:="<=" & Date,
Operator:=xlAnd
End If
End Sub


Cheers,
Lars
 

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

Similar Threads


Top