View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jan Nademlejnsky[_2_] Jan Nademlejnsky[_2_] is offline
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