Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default erase dates over 1 year

I use a spreadsheet to keep track of information. each piece of information
has a cell next to it with the date it was entered. I want the program to
automatically delete any information that is more than 1 year old.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default erase dates over 1 year

Can we have a bit more information?

Where is the date?
what do you want deleting, the entire row?

Mike

"mblhmlbrldll" wrote:

I use a spreadsheet to keep track of information. each piece of information
has a cell next to it with the date it was entered. I want the program to
automatically delete any information that is more than 1 year old.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default erase dates over 1 year

If the dates are in column B, then run:

Sub oldated()
n = Cells(Rows.Count, "B").End(xlUp).Row
cdt = Date - 365
For i = n To 1 Step -1
If Cells(i, 2).Value < cdt Then
Cells(i, 2).EntireRow.Delete
End If
Next
End Sub


So if we start with data in cols A & B like:

data1 1/22/2008
data2 4/4/2007
data3 5/17/2007
data4 6/10/2008
data5 10/26/2007
data6 12/11/2007
data7 2/19/2007
data8 10/6/2007
data9 11/24/2007
data10 7/7/2007
data11 1/19/2007
data12 6/7/2008
data13 7/28/2008
data14 5/20/2008
data15 12/24/2007
data16 9/26/2008
data17 3/5/2008
data18 12/12/2006
data19 1/25/2008
data20 2/27/2007
data21 6/18/2007
data22 6/13/2007
data23 2/12/2007
data24 10/10/2008
data25 9/27/2008
data26 1/22/2007
data27 3/2/2008
data28 6/5/2008
data29 3/18/2007
data30 5/17/2007
data31 11/17/2006

the macro will remove old dates and leave:

data1 1/22/2008
data4 6/10/2008
data5 10/26/2007
data6 12/11/2007
data9 11/24/2007
data12 6/7/2008
data13 7/28/2008
data14 5/20/2008
data15 12/24/2007
data16 9/26/2008
data17 3/5/2008
data19 1/25/2008
data24 10/10/2008
data25 9/27/2008
data27 3/2/2008
data28 6/5/2008

Change the date column to suit your needs.
--
Gary''s Student - gsnu200806


"mblhmlbrldll" wrote:

I use a spreadsheet to keep track of information. each piece of information
has a cell next to it with the date it was entered. I want the program to
automatically delete any information that is more than 1 year old.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default erase dates over 1 year

Instead of this line of code....

Cells(i, 2).EntireRow.Delete

you can use this simpler line of code...

Rows(i).Delete

and it should work the same.

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
If the dates are in column B, then run:

Sub oldated()
n = Cells(Rows.Count, "B").End(xlUp).Row
cdt = Date - 365
For i = n To 1 Step -1
If Cells(i, 2).Value < cdt Then
Cells(i, 2).EntireRow.Delete
End If
Next
End Sub


So if we start with data in cols A & B like:

data1 1/22/2008
data2 4/4/2007
data3 5/17/2007
data4 6/10/2008
data5 10/26/2007
data6 12/11/2007
data7 2/19/2007
data8 10/6/2007
data9 11/24/2007
data10 7/7/2007
data11 1/19/2007
data12 6/7/2008
data13 7/28/2008
data14 5/20/2008
data15 12/24/2007
data16 9/26/2008
data17 3/5/2008
data18 12/12/2006
data19 1/25/2008
data20 2/27/2007
data21 6/18/2007
data22 6/13/2007
data23 2/12/2007
data24 10/10/2008
data25 9/27/2008
data26 1/22/2007
data27 3/2/2008
data28 6/5/2008
data29 3/18/2007
data30 5/17/2007
data31 11/17/2006

the macro will remove old dates and leave:

data1 1/22/2008
data4 6/10/2008
data5 10/26/2007
data6 12/11/2007
data9 11/24/2007
data12 6/7/2008
data13 7/28/2008
data14 5/20/2008
data15 12/24/2007
data16 9/26/2008
data17 3/5/2008
data19 1/25/2008
data24 10/10/2008
data25 9/27/2008
data27 3/2/2008
data28 6/5/2008

Change the date column to suit your needs.
--
Gary''s Student - gsnu200806


"mblhmlbrldll" wrote:

I use a spreadsheet to keep track of information. each piece of
information
has a cell next to it with the date it was entered. I want the program to
automatically delete any information that is more than 1 year old.


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default erase dates over 1 year

Thanks!
--
Gary''s Student - gsnu200806


"Rick Rothstein" wrote:

Instead of this line of code....

Cells(i, 2).EntireRow.Delete

you can use this simpler line of code...

Rows(i).Delete

and it should work the same.

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
If the dates are in column B, then run:

Sub oldated()
n = Cells(Rows.Count, "B").End(xlUp).Row
cdt = Date - 365
For i = n To 1 Step -1
If Cells(i, 2).Value < cdt Then
Cells(i, 2).EntireRow.Delete
End If
Next
End Sub


So if we start with data in cols A & B like:

data1 1/22/2008
data2 4/4/2007
data3 5/17/2007
data4 6/10/2008
data5 10/26/2007
data6 12/11/2007
data7 2/19/2007
data8 10/6/2007
data9 11/24/2007
data10 7/7/2007
data11 1/19/2007
data12 6/7/2008
data13 7/28/2008
data14 5/20/2008
data15 12/24/2007
data16 9/26/2008
data17 3/5/2008
data18 12/12/2006
data19 1/25/2008
data20 2/27/2007
data21 6/18/2007
data22 6/13/2007
data23 2/12/2007
data24 10/10/2008
data25 9/27/2008
data26 1/22/2007
data27 3/2/2008
data28 6/5/2008
data29 3/18/2007
data30 5/17/2007
data31 11/17/2006

the macro will remove old dates and leave:

data1 1/22/2008
data4 6/10/2008
data5 10/26/2007
data6 12/11/2007
data9 11/24/2007
data12 6/7/2008
data13 7/28/2008
data14 5/20/2008
data15 12/24/2007
data16 9/26/2008
data17 3/5/2008
data19 1/25/2008
data24 10/10/2008
data25 9/27/2008
data27 3/2/2008
data28 6/5/2008

Change the date column to suit your needs.
--
Gary''s Student - gsnu200806


"mblhmlbrldll" wrote:

I use a spreadsheet to keep track of information. each piece of
information
has a cell next to it with the date it was entered. I want the program to
automatically delete any information that is more than 1 year old.



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
Add one year to dates Lee D Excel Worksheet Functions 3 December 11th 06 07:43 PM
how do I convert a dates in a year quarters in a year? Linndek Excel Discussion (Misc queries) 2 May 11th 06 03:33 PM
Insert Dates for Year Gladys Excel Discussion (Misc queries) 7 December 7th 05 07:07 PM
dates in year MLD Excel Worksheet Functions 3 September 29th 05 11:03 PM
How can I use day of year dates in Excel? jbradford721 Excel Discussion (Misc queries) 2 August 18th 05 02:56 PM


All times are GMT +1. The time now is 09:55 PM.

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"