Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date Filter | Excel Discussion (Misc queries) | |||
Filter latest date from multiple date entries | Excel Worksheet Functions | |||
Dupliate names with different date Filter for newest date | Excel Discussion (Misc queries) | |||
Date Filter | Excel Discussion (Misc queries) | |||
Date filter using now() | Excel Programming |