NOW function in Autofilter

B

bigsmokey

I have a macro that I've made that needs to autofilter a column of dat
based on the current date/time so I'm trying to use the NOW () functio
in my macro. This is the criteria line in my macro

Selection.AutoFilter Field:=3, Criteria1:="<=" & NOW, Operator:=xlAnd

It errors out saying "expected variable or function".

Anyone have any ideas?

Thanks
 
D

Dave Peterson

That line of code worked fine for me.

But that NOW in uppercase looks weird. Have you given a variable the name NOW?

If yes, find it and change it to something else--don't forget to get all the
instances.
 
D

Debra Dalgleish

That code worked for me.

Did you name a variable NOW?
That could be causing the problem.
 
Top