ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete data if not within date range (https://www.excelbanter.com/excel-programming/355339-delete-data-if-not-within-date-range.html)

Denise

Delete data if not within date range
 
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.


Tom Ogilvy

Delete data if not within date range
 
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

--
Regards,
Tom Ogilvy


"Denise" wrote in message
oups.com...
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.





All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com