Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Geo Geo is offline
external usenet poster
 
Posts: 66
Default Auto deleting data after one year

What is the code for deleting data that is 1 year old ( a rolling year).
Dates are on column A and data runs from columns B to P.
--
Geo
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Auto deleting data after one year

Maybe,

Right click the sheet tab, view code paste this in and run it:-


Sub deleteit()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 1).Value < Date - 365 Then
Range("A" & x & ":P" & x).ClearContents
End If
Next
End Sub

Mike
"Geo" wrote:

What is the code for deleting data that is 1 year old ( a rolling year).
Dates are on column A and data runs from columns B to P.
--
Geo

  #3   Report Post  
Posted to microsoft.public.excel.misc
Geo Geo is offline
external usenet poster
 
Posts: 66
Default Auto deleting data after one year

Thanks Mike,
Did that, but everytime I run it it comes back with the following error:

Compile error:
Variable not defined


--
Geo


"Mike H" wrote:

Maybe,

Right click the sheet tab, view code paste this in and run it:-


Sub deleteit()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 1).Value < Date - 365 Then
Range("A" & x & ":P" & x).ClearContents
End If
Next
End Sub

Mike
"Geo" wrote:

What is the code for deleting data that is 1 year old ( a rolling year).
Dates are on column A and data runs from columns B to P.
--
Geo

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Auto deleting data after one year

Sub deleteit()
dim LastRow as long
...rest of code here
End Sub

Geo wrote:

Thanks Mike,
Did that, but everytime I run it it comes back with the following error:

Compile error:
Variable not defined

--
Geo

"Mike H" wrote:

Maybe,

Right click the sheet tab, view code paste this in and run it:-


Sub deleteit()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 1).Value < Date - 365 Then
Range("A" & x & ":P" & x).ClearContents
End If
Next
End Sub

Mike
"Geo" wrote:

What is the code for deleting data that is 1 year old ( a rolling year).
Dates are on column A and data runs from columns B to P.
--
Geo


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Geo Geo is offline
external usenet poster
 
Posts: 66
Default Auto deleting data after one year

Thanks Dave but I still get the same error message but this time it
highlights 'x' in the code?
Has that got to change as well?
--
Geo


"Dave Peterson" wrote:

Sub deleteit()
dim LastRow as long
...rest of code here
End Sub

Geo wrote:

Thanks Mike,
Did that, but everytime I run it it comes back with the following error:

Compile error:
Variable not defined

--
Geo

"Mike H" wrote:

Maybe,

Right click the sheet tab, view code paste this in and run it:-


Sub deleteit()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 1).Value < Date - 365 Then
Range("A" & x & ":P" & x).ClearContents
End If
Next
End Sub

Mike
"Geo" wrote:

What is the code for deleting data that is 1 year old ( a rolling year).
Dates are on column A and data runs from columns B to P.
--
Geo


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Auto deleting data after one year

The code supplied does not declare the variable 'x' and most likely you have
an Option Explicit statement at the top of you module, which requires that
all variables be declared. Add the following to the procedu

Dim X
' rest of code

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Geo" wrote in message
...
Thanks Dave but I still get the same error message but this time it
highlights 'x' in the code?
Has that got to change as well?
--
Geo


"Dave Peterson" wrote:

Sub deleteit()
dim LastRow as long
...rest of code here
End Sub

Geo wrote:

Thanks Mike,
Did that, but everytime I run it it comes back with the following
error:

Compile error:
Variable not defined

--
Geo

"Mike H" wrote:

Maybe,

Right click the sheet tab, view code paste this in and run it:-


Sub deleteit()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 1).Value < Date - 365 Then
Range("A" & x & ":P" & x).ClearContents
End If
Next
End Sub

Mike
"Geo" wrote:

What is the code for deleting data that is 1 year old ( a rolling
year).
Dates are on column A and data runs from columns B to P.
--
Geo


--

Dave Peterson


  #7   Report Post  
Posted to microsoft.public.excel.misc
Geo Geo is offline
external usenet poster
 
Posts: 66
Default Auto deleting data after one year

Thanks Dave and Gord,
I did retype the code and it works fine now.
Thanks very much for your help and patients.

Cheers!
--
Geo


"Mike H" wrote:

Maybe,

Right click the sheet tab, view code paste this in and run it:-


Sub deleteit()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 1).Value < Date - 365 Then
Range("A" & x & ":P" & x).ClearContents
End If
Next
End Sub

Mike
"Geo" wrote:

What is the code for deleting data that is 1 year old ( a rolling year).
Dates are on column A and data runs from columns B to P.
--
Geo

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Auto deleting data after one year

Geo,
this is Hassan.
Without going into details and on a smaller sample data I tried Mike's first
code it worked without any err.
regards

"Geo" wrote:

Thanks Dave and Gord,
I did retype the code and it works fine now.
Thanks very much for your help and patients.

Cheers!
--
Geo


"Mike H" wrote:

Maybe,

Right click the sheet tab, view code paste this in and run it:-


Sub deleteit()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 1).Value < Date - 365 Then
Range("A" & x & ":P" & x).ClearContents
End If
Next
End Sub

Mike
"Geo" wrote:

What is the code for deleting data that is 1 year old ( a rolling year).
Dates are on column A and data runs from columns B to P.
--
Geo

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
Deleting cell data without deleting formula Tom Hall Excel Discussion (Misc queries) 4 October 29th 06 04:07 PM
Months auto-filter with year twist yadaaa New Users to Excel 4 June 10th 06 02:45 PM
Excel 2002 auto deleting cswasson Excel Discussion (Misc queries) 1 May 23rd 06 01:01 PM
auto deleting defined rows LoriM Excel Discussion (Misc queries) 4 August 4th 05 06:20 PM
Auto Year scale John Sawyer Charts and Charting in Excel 1 July 19th 05 03:18 AM


All times are GMT +1. The time now is 02:44 AM.

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

About Us

"It's about Microsoft Excel"