Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to filter on most current date.

OK...so I hope I can explain this correctly

I need macro code that will auto filter by most recent date(not neccesarily
todays date).

The dates are all input in column A (oldest to newest). Basically the code
needs to be able to open the auto filter for column a and pick the date at
the bottom of the list (since the dates are arranged oldest to newest the
most recent date is at the bottom of the auto filter list.)

Does this make sense to any one besides me?



I recorded a macro where I manually opened the auto filter and chose the
most recent date in column A:

ActiveSheet.Range("$A$1:$K$168").AutoFilter Field:=1, Operator:= _
xlFilterValues, Criteria2:=Array(2, "6/3/2010")

So this code will only filter on 6-3-2010. but as I continue to add more
dates to the database (as time goes on) I need the macro to filter by the
most recent date

is this possible?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Macro to filter on most current date.

Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Travis Patterson" wrote in
message ...
Don,

Right on the money.

Much thanks

Regards,
Travis

I entered that code into my ma

"Don Guillett" wrote:

Sub filterbylastdate()'change column & FORMAT to suit
lr = Cells(Rows.Count, 1).End(xlUp).Row
Rows(6).AutoFilter Field:=1, Criteria1:= _
Format(Cells(lr, 1), "mm/dd/yyyy")
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Travis Patterson" wrote in
message ...
OK...so I hope I can explain this correctly

I need macro code that will auto filter by most recent date(not
neccesarily
todays date).

The dates are all input in column A (oldest to newest). Basically the
code
needs to be able to open the auto filter for column a and pick the date
at
the bottom of the list (since the dates are arranged oldest to newest
the
most recent date is at the bottom of the auto filter list.)

Does this make sense to any one besides me?



I recorded a macro where I manually opened the auto filter and chose
the
most recent date in column A:

ActiveSheet.Range("$A$1:$K$168").AutoFilter Field:=1, Operator:= _
xlFilterValues, Criteria2:=Array(2, "6/3/2010")

So this code will only filter on 6-3-2010. but as I continue to add
more
dates to the database (as time goes on) I need the macro to filter by
the
most recent date

is this possible?





.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Macro to filter on most current date.

It simply finds the last date and formats it so the autofilter will
understand it.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"EZnet" wrote in message
...
Please explain the sub so we can understand how does it work.

"Don Guillett" wrote:

Sub filterbylastdate()'change column & FORMAT to suit
lr = Cells(Rows.Count, 1).End(xlUp).Row
Rows(6).AutoFilter Field:=1, Criteria1:= _
Format(Cells(lr, 1), "mm/dd/yyyy")
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Travis Patterson" wrote in
message ...
OK...so I hope I can explain this correctly

I need macro code that will auto filter by most recent date(not
neccesarily
todays date).

The dates are all input in column A (oldest to newest). Basically the
code
needs to be able to open the auto filter for column a and pick the date
at
the bottom of the list (since the dates are arranged oldest to newest
the
most recent date is at the bottom of the auto filter list.)

Does this make sense to any one besides me?



I recorded a macro where I manually opened the auto filter and chose
the
most recent date in column A:

ActiveSheet.Range("$A$1:$K$168").AutoFilter Field:=1, Operator:= _
xlFilterValues, Criteria2:=Array(2, "6/3/2010")

So this code will only filter on 6-3-2010. but as I continue to add
more
dates to the database (as time goes on) I need the macro to filter by
the
most recent date

is this possible?





.


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
Put current date into a cell when a macro is run jonco Excel Programming 5 July 14th 06 11:31 AM
save workbook as current date using a macro ExcelJon Excel Discussion (Misc queries) 2 June 21st 06 03:05 AM
How do you set cursor position at current date in macro? Tom Robertson Excel Worksheet Functions 1 May 28th 06 03:50 PM
A macro for the today's date...not the current date abxy[_18_] Excel Programming 7 February 8th 04 11:05 PM


All times are GMT +1. The time now is 10:34 PM.

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"