Macro - Date Filter

S

Schwimms

Ok I have a SPREADSHEET1 with a list of data that ranges from the past 15
days, 1-16-08 thru 1-31-08. I have another SPREADSHEET 2 that has data from
1-7-08 thru 1-24-08. I need a macro that finds the latest date on SPREADSHEET
2 and then deletes anything that is less than or equal to on the first
SPREADSHEET 1. This leaves data in SPREADSHEET 1 as 1-25-08 thru 1-31-08.

Any ideas?
 
J

J. Sperry

here's a start, assumes dates are in Column A and there are no blank lines...

Sub DateFilter()
Dim lMaxDate As Long

Application.Workbooks("SPREADSHEET 2").Activate
Range("A1").Select
lMaxDate = 0
Do While ActiveCell.Value > 0
If ActiveCell.Value > lMaxDate Then lMaxDate = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Loop
Application.Workbooks("SPREADSHEET 1").Activate
Range("A1").Select
Do While ActiveCell.Value > 0
If ActiveCell.Value <= lMaxDate Then ActiveCell.Clear
ActiveCell.Offset(1, 0).Select
Loop
End Sub
 
Top