View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Autofilter Criteria not filtering when using NOW()

If they are dates this is working OK here for column A
And Tom's example will also work.

Columns("A").AutoFilter Field:=1, Criteria1:="<=" & DateSerial(Year(Date), Month(Date), Day(Date))

Maybe this is not correct
Range("Note1").Column


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Peter T" <peter_t@discussions wrote in message ...
I jumped in a bit too quick without fully testing, ignore that. There's a
bit more to it!

Ron & Tom, neither of yours work for me either.

Regards,
Peter T

"Peter T" <peter_t@discussions wrote in message
...
Another attempt -

Sub test()
Dim s As String

' asssumes all cells below the header have same date format
s = Range("Note1").Offset(1).NumberFormat

Selection.AutoFilter Field:=Range("Note1").Column, _
Criteria1:="<=" & Format(Now(), s)
End Sub

Regards,
Peter T

"bony_tony" wrote in message
ups.com...
Still doesn't work.. Same problem..


On 24 Aug, 15:08, "Ron de Bruin" wrote:
Try DateSerial

Selection.AutoFilter Field:=Range("Note1").Column, Criteria1:="<=" &

DateSerial(Year(Date), Month(Date), Day(Date))

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"bony_tony" wrote in

oglegroups.com...
Hi,
I have this line of code.

Selection.AutoFilter Field:=Range("Note1").Column, Criteria1:="<=" &
Format(Now(), "dd/mm/yyyy")

I want to filter anything dated today or prior.

It's not working - every line is being filtered out. When I drop

down
the autofilter button for the column, and go to 'Custom' I can see

the
correct date is in the dialog box, and the filter works when I press
OK through it.

Anyone know why this isn't working?

Cheers
Tony- Hide quoted text -

- Show quoted text -