Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting autofilter at runtime
Hello,
I am trying to set an autofilter to a custom filter when a user clicks command button. The code I have linked to the button follows. The goal is to get the autofilter to return rows where the date in the field is less than or equal to today. I think I can see that the problem is that the code is seeing the string "=Now" as a literal string without evaluting the expression within it. Dim lDate As Date Selection.AutoFilter Field:=12, Criteria1:="<= Now", Operator:=xlAnd End Sub Any help would be greatly appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting autofilter at runtime
Selection.AutoFilter Field:=12, Criteria1:="<=" & Now
HTH -- AP "AD108" a écrit dans le message de news: ... Hello, I am trying to set an autofilter to a custom filter when a user clicks command button. The code I have linked to the button follows. The goal is to get the autofilter to return rows where the date in the field is less than or equal to today. I think I can see that the problem is that the code is seeing the string "=Now" as a literal string without evaluting the expression within it. Dim lDate As Date Selection.AutoFilter Field:=12, Criteria1:="<= Now", Operator:=xlAnd End Sub Any help would be greatly appreciated. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting autofilter at runtime
Thanks,
That made it work. "Ardus Petus" wrote in message ... Selection.AutoFilter Field:=12, Criteria1:="<=" & Now HTH -- AP "AD108" a écrit dans le message de news: ... Hello, I am trying to set an autofilter to a custom filter when a user clicks command button. The code I have linked to the button follows. The goal is to get the autofilter to return rows where the date in the field is less than or equal to today. I think I can see that the problem is that the code is seeing the string "=Now" as a literal string without evaluting the expression within it. Dim lDate As Date Selection.AutoFilter Field:=12, Criteria1:="<= Now", Operator:=xlAnd End Sub Any help would be greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
autofilter macro setting | Excel Worksheet Functions | |||
Macro runtime error 1004 with Autofilter | Excel Discussion (Misc queries) | |||
Setting autofilter criteria | Excel Programming | |||
Propblem setting OnAction property at runtime | Excel Programming | |||
Setting AutoFilter to 1 row of data | Excel Programming |