A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Delete entire row if older then 365 days



 
 
Thread Tools Display Modes
  #1  
Old April 3rd, 2010, 11:31 PM posted to microsoft.public.excel.misc
PAS
external usenet poster
 
Posts: 34
Default Delete entire row if older then 365 days

How do I create a macro that will delete entire row if older then 365 days.
Dates are on col "A"
last col of data = "U"
Data is kept in sheet "details"

Thank you
  #2  
Old April 4th, 2010, 04:03 AM posted to microsoft.public.excel.misc
ozgrid.com
external usenet poster
 
Posts: 328
Default Delete entire row if older then 365 days

Try;


Sub DeleteOldDates()
Dim lDate As Long

lDate = Date - 365
With Sheets("details")
.AutoFilterMode = False
.Range("A1:A2").AutoFilter Field:=1, Criteria1:="" & lDate
.AutoFilter.Range.Offset(1,
0).SpecialCells(xlCellTypeVisible).EntireRow.Delet e
.AutoFilterMode = False
End With

End Sub



--
Regards
Dave Hawley
www.ozgrid.com
"Pas" wrote in message
...
How do I create a macro that will delete entire row if older then 365
days.
Dates are on col "A"
last col of data = "U"
Data is kept in sheet "details"

Thank you


  #3  
Old April 4th, 2010, 10:13 PM posted to microsoft.public.excel.misc
PAS
external usenet poster
 
Posts: 34
Default Delete entire row if older then 365 days

Sorry guys,
I'm still getting error messages with both suggestions.
How do I declare the variables R, and LR as Integers .


"ozgrid.com" wrote:

Try;


Sub DeleteOldDates()
Dim lDate As Long

lDate = Date - 365
With Sheets("details")
.AutoFilterMode = False
.Range("A1:A2").AutoFilter Field:=1, Criteria1:="" & lDate
.AutoFilter.Range.Offset(1,
0).SpecialCells(xlCellTypeVisible).EntireRow.Delet e
.AutoFilterMode = False
End With

End Sub



--
Regards
Dave Hawley
www.ozgrid.com
"Pas" wrote in message
...
How do I create a macro that will delete entire row if older then 365
days.
Dates are on col "A"
last col of data = "U"
Data is kept in sheet "details"

Thank you


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:25 AM.


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