Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
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
Date(Year,Month,Day) not returnign correct date jlclyde Excel Discussion (Misc queries) 8 October 16th 09 02:42 PM
Determine year over year date for comparison zeroscou Excel Worksheet Functions 3 March 6th 09 10:01 PM
Procedure to update a DATE field to either a year from now or a year from what is in the field? Andrew[_57_] Excel Programming 5 January 13th 08 05:15 PM
Year-to-date year to date formula Philm Excel Worksheet Functions 1 October 7th 05 02:50 AM
Date formula: return Quarter and Fiscal Year of a date Rob Excel Discussion (Misc queries) 7 May 11th 05 08:48 PM


All times are GMT +1. The time now is 07:57 AM.

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

About Us

"It's about Microsoft Excel"