LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Deleting rows older than current date and inserting a new row

I have a workbook which contains a worksheet that has project data, including
project end date. Users update the sheet with current and projected
projects. I have written a macro to remove entries whose end date (in column
"G") are older than the current date.

The macro as written works, however when I run the macro it inserts a blank
row for every project listed in the spreadsheet. How do I get it to insert a
new row only when it deletes a row? And how do I make sure that the new,
inserted row is at the bottom of the formatted data (which ends at row 31)?

Sub DeleteOldRows()
Dim LastRow As Long, xR As Long
With ActiveSheet
LastRow = .Cells(Rows.Count, "G").End(xlUp).Row
For xR = LastRow To 6 Step -1
If .Cells(xR, "G") < Date Then _
Rows(xR).EntireRow.Delete
Rows(31).EntireRow.Insert
Next xR
End With

End Sub

Thanks for your help!
 
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
CF goes crazy when deleting/inserting rows DoubleZ Excel Discussion (Misc queries) 1 October 2nd 08 09:33 PM
Inserting current date pdaws Excel Worksheet Functions 8 September 25th 08 12:37 AM
I want any date 90 days or older from current date change color Big Abalone Excel Worksheet Functions 5 April 23rd 06 05:01 AM
Inserting Data Beneath Current Rows Jasper Excel Programming 3 February 21st 05 03:10 PM
Deleting 3 rows when current row number is unknown Joe[_31_] Excel Programming 1 May 20th 04 06:41 AM


All times are GMT +1. The time now is 10:33 PM.

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

About Us

"It's about Microsoft Excel"