bbqsmokeman
New Member
I have had great help in the past on this workbook and am still learning.
I know this is probably simple but for some reason no matter which macros I use it messes the sheets calendars or doesn't work.
Basically I created a 'sort' macro to run in A15:J500 and once complete move all data down one row to leave A14 open for new entry. The code works real good and fast so I thought I would now add a macro to check dates A15 downwards and if 365 days old from recent entry or today() then delete rows (similar to keeping a rolling calendar). One macro deleted almost everything even the calendars and one doesn't seem to function at all. I know it's probably something real simple but it eludes me
Codes I have tried but are not working:
I didn't want to keep rewriting code so i expressioned out the ones that I couldn't get working except most recent one which is active but wanted to keep them for reference to study more.
I am including the sample and it may look familiar as it was recently up here for help earlier.
I am still reviewing the recent code (calendar transfer each year) as I need to understand it so I can modify and apply to the 'summary' sheet as well.
Can the date older than 365 run from the 'summary' and move across all the worksheets like the calendar macro?
thanks
I know this is probably simple but for some reason no matter which macros I use it messes the sheets calendars or doesn't work.
Basically I created a 'sort' macro to run in A15:J500 and once complete move all data down one row to leave A14 open for new entry. The code works real good and fast so I thought I would now add a macro to check dates A15 downwards and if 365 days old from recent entry or today() then delete rows (similar to keeping a rolling calendar). One macro deleted almost everything even the calendars and one doesn't seem to function at all. I know it's probably something real simple but it eludes me
Codes I have tried but are not working:
Code:
Sub DeleteOlder()
'Delete rows if expiry date < today + 365
For i = 15 To FinalRow
If Range("A" & i).Value < Date + 365 Then
Rows(i).Delete
End If
Next i
End Sub
'Sub DeleteOlder()
'lr = Cells(Rows.Count, "A").End(xlUp).Row
'Range("A15:A" & lr).AutoFilter Field:=1, _
'Criteria1:="<" & Date - 365
'Range("A15:A" & lr) _
'.SpecialCells(xlCellTypeVisible).EntireRow.Delete
'Range("A15:A" & lr).AutoFilter
'End Sub
'Sub DeleteOlder()
'lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
'For x = lastrow To 15 Step -1
'If Cells(x, 15).Value <= Date - 365 Then
'Cells(x, 15).EntireRow.Delete
'End If
'Next
'End Sub
I didn't want to keep rewriting code so i expressioned out the ones that I couldn't get working except most recent one which is active but wanted to keep them for reference to study more.
I am including the sample and it may look familiar as it was recently up here for help earlier.
I am still reviewing the recent code (calendar transfer each year) as I need to understand it so I can modify and apply to the 'summary' sheet as well.
Can the date older than 365 run from the 'summary' and move across all the worksheets like the calendar macro?
thanks