Deleting Rows with a macro based on a date value

M

Max2073

I have a spreadsheet with 8000 rows. In column E I have dates (estimated
completion dates) - I would like to delete rows that are are not due within
the next seven days and/or which are not overdue.

eg. Today - 7 September 2009 - I would like to leave all rows that are due
upto the 14 September 2009 (left in the spreadsheet would be any outstanding
records that are overdue eg. 10 August 2009.
 
J

Jacob Skaria

Try the below macro which works on the active sheet

Sub MyMacro()
Dim lngRow As Long
For lngRow = Cells(Rows.Count, "E").End(xlUp).Row To 2 Step -1
If Range("E" & lngRow) > Date + 7 Then Rows(lngRow).Delete
Next
End Sub

If this post helps click Yes
 
M

Max2073

Thank you for your assistance - works great just what I was after.

Is it possible to get some more help from you:

Column D in my spreadsheet contains either a Date value or the word "NULL".
I would like to move all rows with a date value in Column D to Sheet 2 by
macro. The original row should be removed from Sheet1.
 

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