Creating date literal

S

Stefi

Hi,
is it possible to create a date literal from a variable?
I tried the method as follows:
datelit = "#" & month & "/" & day & "/" & year & "#"
Selection.AutoFilter Field:=1, Criteria1:=">=" & datelit
but it doesn't work!
I need this because using a date literal seems to be the only solution to
the problem I asked in my question "Autofilter in VB on date field,
12.01.2004".
Here is the original question:
"Applying Autofilter on a date field in a macro results in no matching rows
no matter what were the field values and the criteria. Breaking the macro
just after the Autofilter statement and in interactive mode having a look at
the filter setting of the column in question it shows the intended values .
Making NO changes and pushing the OK button results in correct filtering: the
rows matching the criteria are shown."
Using an actual literal, e.g.
Selection.AutoFilter Field:=1, Criteria1:=">=" & #12/01/2004#
works properly, but I have the date value in a variable.
Any idea?
Thanks, Stefi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top