Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 40
Default Deleting Rows with a macro based on a date value

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.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Deleting Rows with a macro based on a date value

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
---------------
Jacob Skaria


"Max2073" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 40
Default Deleting Rows with a macro based on a date value

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.

"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"Max2073" wrote:

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Rows based on a Value Max2073 Excel Worksheet Functions 2 August 14th 09 01:34 PM
Macro to delete rows based on date PMBO Excel Discussion (Misc queries) 4 February 18th 09 01:50 PM
Deleting Rows based on Column Critieria blackmanofsteel40 Excel Discussion (Misc queries) 1 September 7th 07 09:05 PM
Deleting rows based on IF statement simmerdown Excel Discussion (Misc queries) 1 September 9th 05 02:18 PM
Deleting rows based on a cell value JPriest Excel Worksheet Functions 3 August 12th 05 05:44 PM


All times are GMT +1. The time now is 08:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"