Delete data if not within date range

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.
 
T

Tom Ogilvy

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
 

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