Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto Filter and Criteria1 variable
I'm trying to code a worksheet filter by using a variable as < Criteria1 . The variable < dteFilterDate will be set by an InputBox, and has been dimensioned as a DATE. The following line of code gives me a run time error #1004, AutoFilter method of Range class failed
Selection.AutoFilter Field:=18, Criteria1:="<= " & dteFilterDate I've probably got a syntax problem, but haven't found the right combination of characters. Any ideas? D.S. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto Filter and Criteria1 variable
This worked for me:
Sub AAA2() Dim dteFilterDate As Date dteFilterDate = CDate(InputBox("Enter date")) Range("AK2").CurrentRegion.Select Selection.AutoFilter Field:=18, Criteria1:="<= " & CLng(dteFilterDate) End Sub -- Regards, Tom Ogilvy D.S. wrote in message ... I'm trying to code a worksheet filter by using a variable as < Criteria1 . The variable < dteFilterDate will be set by an InputBox, and has been dimensioned as a DATE. The following line of code gives me a run time error #1004, AutoFilter method of Range class failed Selection.AutoFilter Field:=18, Criteria1:="<= " & dteFilterDate I've probably got a syntax problem, but haven't found the right combination of characters. Any ideas? D.S. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto Filter and Criteria1 variable
Thanks again Tom. Just what I needed, worked for me too.
D.S. "Tom Ogilvy" wrote in message ... This worked for me: Sub AAA2() Dim dteFilterDate As Date dteFilterDate = CDate(InputBox("Enter date")) Range("AK2").CurrentRegion.Select Selection.AutoFilter Field:=18, Criteria1:="<= " & CLng(dteFilterDate) End Sub -- Regards, Tom Ogilvy D.S. wrote in message ... I'm trying to code a worksheet filter by using a variable as < Criteria1 . The variable < dteFilterDate will be set by an InputBox, and has been dimensioned as a DATE. The following line of code gives me a run time error #1004, AutoFilter method of Range class failed Selection.AutoFilter Field:=18, Criteria1:="<= " & dteFilterDate I've probably got a syntax problem, but haven't found the right combination of characters. Any ideas? D.S. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel auto-filter does not filter certain columns | Excel Discussion (Misc queries) | |||
DataFilterAuto Filter in excel 2007? | New Users to Excel | |||
Excel 2007 Auto Filter Filter | Excel Discussion (Misc queries) | |||
Limit filter options in Auto Filter | Excel Discussion (Misc queries) | |||
Excel auto filter doesn't recoginize case - won't filter AA from A | Excel Discussion (Misc queries) |