Delete data if not within date range

  • Thread starter Thread starter Denise
  • Start date Start date
D

Denise

I have a cumbersome spread sheet that contains over 20,000 rows that
includes a date column. Using the current date as a reference point, I
would like to delete all rows 14 days prior to today and 14 days after
today. Any help would be appreciated.
 
assuming you mean farther away from today's date than 14 days and not 14
days exactly,

set lastrow = cells(rows.count,"C").End(xlup)
for lastrow to 2 step -1
if abs(Date-Int(cells(i,"C"))) > 14 then
rows(i).Delete
end if
Next

adjust the ">" to ">=" if you want to delete dates exactly 14 days away
 
Back
Top