Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Dydnamic date in an autofilter

I need to do an "and" filter on a date field in Excel 2003.

I have tried this and other variations.

Dim Current_Date, Previous_Date
Current_Date = Date
Previous_Date = Date - 14
'
Selection.AutoFilter Field:=1, Criteria1:="="Previous_Date,
Operator:=xlAnd _
, Criteria2:="=<"Current_Date

Any ideas how to get the dynamic dates to work in the Autofilter?

Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Dydnamic date in an autofilter

Hi Ron

Or use two cells on your worksheet with the dates

rng.AutoFilter Field:=4, Criteria1:="=" & CLng(Range("B1").Value), _
Operator:=xlAnd, Criteria2:="<=" & CLng(Range("C1").Value)

You can change the cell reference to Date and Date -14

See also this add-in
http://www.rondebruin.nl/easyfilter.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ron Luzius" wrote in message ...
I need to do an "and" filter on a date field in Excel 2003.

I have tried this and other variations.

Dim Current_Date, Previous_Date
Current_Date = Date
Previous_Date = Date - 14
'
Selection.AutoFilter Field:=1, Criteria1:="="Previous_Date,
Operator:=xlAnd _
, Criteria2:="=<"Current_Date

Any ideas how to get the dynamic dates to work in the Autofilter?

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Dydnamic date in an autofilter

You gave me the just hint I was looking for. I totally didn't think about
using the join "&" in the autofilter.
I did this and gave me exactly what I wanted to do. I was Sooo close!

Thanks for the extra set of eyes on this!

Dim Previous_Date, Current_Date
Current_Date = Date
Previous_Date = Current_Date - 5


Range("A1").Select
Selection.AutoFilter

Selection.AutoFilter Field:=1, Criteria1:="=" & Previous_Date,
Operator:=xlAnd _
, Criteria2:="<=" & Current_Date



"Ron de Bruin" wrote in message
...
Hi Ron

Or use two cells on your worksheet with the dates

rng.AutoFilter Field:=4, Criteria1:="=" & CLng(Range("B1").Value), _
Operator:=xlAnd, Criteria2:="<=" & CLng(Range("C1").Value)

You can change the cell reference to Date and Date -14

See also this add-in
http://www.rondebruin.nl/easyfilter.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ron Luzius" wrote in message
...
I need to do an "and" filter on a date field in Excel 2003.

I have tried this and other variations.

Dim Current_Date, Previous_Date
Current_Date = Date
Previous_Date = Date - 14
'
Selection.AutoFilter Field:=1, Criteria1:="="Previous_Date,
Operator:=xlAnd _
, Criteria2:="=<"Current_Date

Any ideas how to get the dynamic dates to work in the Autofilter?

Thanks!


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
Autofilter a Date range Steen Excel Discussion (Misc queries) 0 November 25th 06 08:23 PM
Why I can't autofilter date (01-Jul-06 to 31-Jul-06) in Exel? elephant Excel Discussion (Misc queries) 1 August 9th 06 02:28 PM
Autofilter with date field gabch[_2_] Excel Programming 1 February 14th 06 11:49 AM
Date flips around when using Autofilter in VB elsandalos Excel Programming 4 February 24th 05 01:53 PM
Custom Date in Autofilter Michael Singmin Excel Programming 3 June 15th 04 11:14 PM


All times are GMT +1. The time now is 09:00 AM.

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

About Us

"It's about Microsoft Excel"