Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to Filter Date?

I need to create macro which will pick a date from C1 and then select all
records with dates <= than this date. Also my date format shown is mm/dd/yy,
but when read into FilterDate it is in mm/dd/yyyy. Is there any way to force
FilterDate into mm/dd/yy?

See example, please. I am struggling with the & and """ order. I need to fix
the last line
C1 and Column 11 (Field 11) are formatted mm/dd/yy

Dim FilterDate as Date
Sub test()
FilterDate = Range("C1") '10/01/98
Range("K3").Select
Application.CutCopyMode = False
'Selection.AutoFilter Field:=11, Criteria1:="<=10/01/1998"
'Selection.AutoFilter Field:=11, Criteria1:=FilterDate ' this works
Selection.AutoFilter Field:=11, Criteria1:="&" <= "&FilterDate" 'this
does not work
End Sub

Thanks for your help

Jan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How to Filter Date?

Sometimes this works:

FilterDate = clng(Range("C1")) '10/01/98
or equivalently
Selection.AutoFilter Field:=11, Criteria1:="<=" & clng(dateserial(1998,10,1))




Jan Nademlejnsky wrote:

I need to create macro which will pick a date from C1 and then select all
records with dates <= than this date. Also my date format shown is mm/dd/yy,
but when read into FilterDate it is in mm/dd/yyyy. Is there any way to force
FilterDate into mm/dd/yy?

See example, please. I am struggling with the & and """ order. I need to fix
the last line
C1 and Column 11 (Field 11) are formatted mm/dd/yy

Dim FilterDate as Date
Sub test()
FilterDate = Range("C1") '10/01/98
Range("K3").Select
Application.CutCopyMode = False
'Selection.AutoFilter Field:=11, Criteria1:="<=10/01/1998"
'Selection.AutoFilter Field:=11, Criteria1:=FilterDate ' this works
Selection.AutoFilter Field:=11, Criteria1:="&" <= "&FilterDate" 'this
does not work
End Sub

Thanks for your help

Jan


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Filter Rao Ratan Singh Excel Discussion (Misc queries) 2 December 2nd 09 02:15 PM
Filter latest date from multiple date entries [email protected] Excel Worksheet Functions 1 July 4th 08 09:40 PM
Dupliate names with different date Filter for newest date Becky Excel Discussion (Misc queries) 1 April 8th 07 08:38 PM
Date Filter tech lead Excel Discussion (Misc queries) 1 November 18th 05 04:37 AM
Date filter using now() Bruce[_5_] Excel Programming 0 September 2nd 03 11:57 PM


All times are GMT +1. The time now is 02:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"