View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] lars.knutus@gmx.net is offline
external usenet poster
 
Posts: 2
Default Strange behaviour of autofilter

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