Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default 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
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
Excel auto-filter does not filter certain columns Eric_NY Excel Discussion (Misc queries) 5 November 29th 08 10:13 AM
DataFilterAuto Filter in excel 2007? TIJ New Users to Excel 2 November 13th 08 03:28 AM
Excel 2007 Auto Filter Filter Django Excel Discussion (Misc queries) 2 September 9th 08 10:52 PM
Limit filter options in Auto Filter lista72 Excel Discussion (Misc queries) 1 January 23rd 08 04:01 PM
Excel auto filter doesn't recoginize case - won't filter AA from A Mikey Excel Discussion (Misc queries) 1 September 29th 05 08:18 PM


All times are GMT +1. The time now is 03:18 AM.

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"