Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Auto deleting data after one year | Excel Discussion (Misc queries) | |||
Deleting Identical Entries | Excel Worksheet Functions | |||
deleting blank entries | Excel Discussion (Misc queries) | |||
Deleting duplicate entries | Excel Discussion (Misc queries) | |||
Deleting BOTH duplicate entries | Excel Discussion (Misc queries) |