MichaelL
01-09-2007, 04:01 AM
Hello
I have a small problem with a piece of code, and couldn't find anything similar when i searched the forum.
I'm trying to write a short piece of code which looks at the date in a specific cell and deletes the corresponding row of data if the date is prior to yesterday. The purpose is to clear old data from a table.
So far i have tried variations on the following two loops:
Do Until ActiveCell.FormulaR1C1 = "=TODAY()-1"
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("A2").Select
Loop
Do Until Range("A2") = "=TODAY()-1"
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("A2").Select
Loop
I've tried them with Do While loops as well, to no joy. Each time I step through, the loop continues indefinitely, which leads me to believe that the criteria I have set are somehow incorrect.
Any pointers would be appreciated!
Thanks
Michael
I have a small problem with a piece of code, and couldn't find anything similar when i searched the forum.
I'm trying to write a short piece of code which looks at the date in a specific cell and deletes the corresponding row of data if the date is prior to yesterday. The purpose is to clear old data from a table.
So far i have tried variations on the following two loops:
Do Until ActiveCell.FormulaR1C1 = "=TODAY()-1"
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("A2").Select
Loop
Do Until Range("A2") = "=TODAY()-1"
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("A2").Select
Loop
I've tried them with Do While loops as well, to no joy. Each time I step through, the loop continues indefinitely, which leads me to believe that the criteria I have set are somehow incorrect.
Any pointers would be appreciated!
Thanks
Michael