K
Ken G
I have a macro that deletes returned records older than 7 days. It first sorts the data into returned date order then checks to see if the first cell is empty (no records returned) and if so, re-sorts the data into the original order (a different date) and quits. If the first cell contains a date less than 7 days old ie date >today()-7, again it re-sorts and quits, otherwise it deletes the data older than 7 days, re-sorts the remaining data and quits. At least that what is supposed to happen
The line to check the age of the date in the macro below doesn't work. G6 contains a control date displayed in the worksheet being "today()-7" If I do the comparison in the worksheet itself with a yes/no cell to store the result, then have the macro check for yes/no, it works. It also doesn't work if I use "If selection >= today()-7
This is the macro
Sub Clean_up(
' Clean_up Macr
' Macro recorded 7/06/2004 by ken
Dim ans As Strin
ans = MsgBox("Deletion of returned files is permanent and irreversible. Do you wish to proceed?", vbYesNo
If ans = vbYes Then GoTo SortMod Else Exit Su
SortMod
Range("A7
ffset(A6,G1-6,5)").Selec
Selection.Sort Key1:=Range("F7"), Order1:=xlAscending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBotto
Range("F7").Selec
If Selection = "" Then GoTo DateSort Els
If Selection >= G6 Then GoTo DateSort Else [This is the line that doesn't work
Range("A7
ffset(A6,G5,5)").Selec
Selection.Delet
DateSort
Run ["Date_Sort"
End Su
Thanks
Ken G.
The line to check the age of the date in the macro below doesn't work. G6 contains a control date displayed in the worksheet being "today()-7" If I do the comparison in the worksheet itself with a yes/no cell to store the result, then have the macro check for yes/no, it works. It also doesn't work if I use "If selection >= today()-7
This is the macro
Sub Clean_up(
' Clean_up Macr
' Macro recorded 7/06/2004 by ken
Dim ans As Strin
ans = MsgBox("Deletion of returned files is permanent and irreversible. Do you wish to proceed?", vbYesNo
If ans = vbYes Then GoTo SortMod Else Exit Su
SortMod
Range("A7
Selection.Sort Key1:=Range("F7"), Order1:=xlAscending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBotto
Range("F7").Selec
If Selection = "" Then GoTo DateSort Els
If Selection >= G6 Then GoTo DateSort Else [This is the line that doesn't work
Range("A7
Selection.Delet
DateSort
Run ["Date_Sort"
End Su
Thanks
Ken G.