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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|