Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
AOP AOP is offline
external usenet poster
 
Posts: 23
Default Deleting entries one year old

I have the following code which deletes all entries that are one year old to
date.

Private Sub deleteit()
Dim LastRow As Long
Dim X
LastRow = Range("A20000").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

This code works well, but what I need is only to clear columns A to F and H.
I need it to leave column G alone because it has formulas.

--
AOP
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 638
Default Deleting entries one year old

One way:
Range("A" & X & ":F" & X & ",H" & X).ClearContents

AOP wrote:
I have the following code which deletes all entries that are one year old to
date.

Private Sub deleteit()
Dim LastRow As Long
Dim X
LastRow = Range("A20000").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

This code works well, but what I need is only to clear columns A to F and H.
I need it to leave column G alone because it has formulas.

--
AOP


  #3   Report Post  
Posted to microsoft.public.excel.misc
AOP AOP is offline
external usenet poster
 
Posts: 23
Default Deleting entries one year old

Thanks that works well
--
AOP


"JW" wrote:

One way:
Range("A" & X & ":F" & X & ",H" & X).ClearContents

AOP wrote:
I have the following code which deletes all entries that are one year old to
date.

Private Sub deleteit()
Dim LastRow As Long
Dim X
LastRow = Range("A20000").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

This code works well, but what I need is only to clear columns A to F and H.
I need it to leave column G alone because it has formulas.

--
AOP



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
Auto deleting data after one year Geo Excel Discussion (Misc queries) 15 October 15th 07 09:20 AM
Deleting Identical Entries SV Excel Worksheet Functions 2 December 12th 06 12:45 AM
deleting blank entries mikeyVo Excel Discussion (Misc queries) 1 August 4th 06 06:30 AM
Deleting duplicate entries J. Gutierrez Excel Discussion (Misc queries) 3 November 4th 05 11:05 AM
Deleting BOTH duplicate entries Julian Excel Discussion (Misc queries) 2 March 7th 05 11:54 PM


All times are GMT +1. The time now is 04:44 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"