View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
AD108 AD108 is offline
external usenet poster
 
Posts: 72
Default 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.