I'm trying to move a row within a range of cells from 1 sheet to another, then delete that information off the original sheet. The criteria for moving the row or not is based on a date. I want anything older than 7 days from today to be moved to a history page and removed from the current page. This is updated daily.
I've gotten it to basically work except for some reason it will not move a date with the 7th day of the month in it. It appears to work because it's no longer on the current page, however, it is also not on the history page.
Below is the code I'm using.
I've gotten it to basically work except for some reason it will not move a date with the 7th day of the month in it. It appears to work because it's no longer on the current page, however, it is also not on the history page.
Below is the code I'm using.
Code:
Dim Today
Today = Now ' Assign current system date and time.
DATA = Sheets("Current Orders In Process").Range("o4:o100")
CROW = 4
For Each RDATA In DATA
If RDATA <> 0 And RDATA < Now() - 7 Then
Rows(CROW & ":" & CROW).Select
Selection.Copy
Sheets("History - Past Orders").Select
Rows("5:5").Select
Selection.Insert Shift:=xlDown
Sheets("Current Orders In Process").Select
Rows(CROW & ":" & CROW).ClearContents
End If
CROW = CROW + 1
Next
What happens with this is when the date is say 8/7/07, it deletes it from current but it does not copy it to the history.
There are also additional rows in the sheet that do not have dates in the column yet that I do not want moved. That's why I have the does not equal 0 part in the code.
I'm fairly new to code and just have not been able to figure out what's wrong.
Thanks for your help