ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Strange behaviour of autofilter (https://www.excelbanter.com/excel-programming/397009-strange-behaviour-autofilter.html)

[email protected]

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



All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com