Filter macro

T

Tasha

I am trying to create a macro that will filter column B which is a listing of
dates from last year, same month. So, for instance this months report
contains dates listed from March 2007. I need to filter for dates that are
less than todays date. So, anything from the 19th of 2007 forward would need
to be deleted. This will change every day. Tomorrow will need the 20th
forward rows deleted. This is what I have from trying to create the macro,
but I need the date to be dynamic. What I have will only select accounts I
specify today, and will only delete the rows I manually selected after the
filter. Can anyone help me with this?

Sub Deletedays()

' Deletefromtodaysdateforward Macro
'
Columns("B:B").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=">3/18/2007", Operator:=xlAnd
Rows("189:302").Select
Selection.Delete Shift:=xlUp

End Sub
 
D

Dave Peterson

Selection.AutoFilter Field:=1, Criteria1:=">3/18/2007", Operator:=xlAnd
becomes
Selection.AutoFilter Field:=1, Criteria1:=">" & format(date,"mm/dd/yyyy")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top