Hi all, I am stumped with a problem involving a loop that searches back 1 week. As it is, my loop will search each cell looking for the date that is 7 days ago. It works fine until it finds that the date is not there. For example, 7 days ago was a Canadian holiday and therefore no update was made to my spreadsheet on the 1st of July. Being that, my loop skips right past and procedes to the top of the page and right into a runtime error. Basically, I need to implement a code that says: If the date does not exist, then stop on the day following (eg July 2). Here is my code:
Dim CurrentDate As Date
Dim CompareDate As Date
Application.Worksheets("CdnDaily").Select
Range("CdnDailyDate").End(xlDown).Select
CurrentDate = ActiveCell.Value
CompareDate = CurrentDate - 7
Do While ActiveCell.Value <> CompareDate
ActiveCell.Offset(-1, 0).Select
Loop
I hope this is clear enough, please let me know if you need more.
Cheers:
Mordred
Bookmarks