Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleteing date over 1 year old
I have a few columns of dates with coresponding numbers in the next column. I
am trying to delete the dates older then one year from Today() and the coresponding number in the next column. These dates are in order so when it runs out of dates OR the date is less then one year I would like it to go over 5 colums and do it again until it runs out of data. I know most people post the code they are trying to use but in this case I am looking for a completely fresh perspective. Any help would be appriciated =) Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleteing date over 1 year old
This should do what you want: Code: -------------------- Sub remove_old_dates() Dim Rng As Range, Mycell As Range Dim i As Long, ic As Long 'MsgBox ActiveSheet.UsedRange.Columns.Count Set Rng = ActiveSheet.UsedRange For ic = 1 To ActiveSheet.UsedRange.Columns.Count Step 5 For i = ActiveSheet.UsedRange.Rows.Count To 1 Step -1 If Cells(i, ic).Value < Date - 365 Then Cells(i, ic).EntireRow.Delete End If Next i Next ic End Sub -------------------- Wolfwalker721;490100 Wrote: I have a few columns of dates with coresponding numbers in the next column. I am trying to delete the dates older then one year from Today() and the coresponding number in the next column. These dates are in order so when it runs out of dates OR the date is less then one year I would like it to go over 5 colums and do it again until it runs out of data. I know most people post the code they are trying to use but in this case I am looking for a completely fresh perspective. Any help would be appriciated =) Thanks! -- Simon Lloyd Regards, Simon Lloyd 'Microsoft Office Help' (http://www.thecodecage.com) ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=135104 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleteing date over 1 year old
THANKS!!
"Simon Lloyd" wrote: This should do what you want: Code: -------------------- Sub remove_old_dates() Dim Rng As Range, Mycell As Range Dim i As Long, ic As Long 'MsgBox ActiveSheet.UsedRange.Columns.Count Set Rng = ActiveSheet.UsedRange For ic = 1 To ActiveSheet.UsedRange.Columns.Count Step 5 For i = ActiveSheet.UsedRange.Rows.Count To 1 Step -1 If Cells(i, ic).Value < Date - 365 Then Cells(i, ic).EntireRow.Delete End If Next i Next ic End Sub -------------------- Wolfwalker721;490100 Wrote: I have a few columns of dates with coresponding numbers in the next column. I am trying to delete the dates older then one year from Today() and the coresponding number in the next column. These dates are in order so when it runs out of dates OR the date is less then one year I would like it to go over 5 colums and do it again until it runs out of data. I know most people post the code they are trying to use but in this case I am looking for a completely fresh perspective. Any help would be appriciated =) Thanks! -- Simon Lloyd Regards, Simon Lloyd 'Microsoft Office Help' (http://www.thecodecage.com) ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=135104 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date(Year,Month,Day) not returnign correct date | Excel Discussion (Misc queries) | |||
Determine year over year date for comparison | Excel Worksheet Functions | |||
Procedure to update a DATE field to either a year from now or a year from what is in the field? | Excel Programming | |||
Year-to-date year to date formula | Excel Worksheet Functions | |||
Date formula: return Quarter and Fiscal Year of a date | Excel Discussion (Misc queries) |