I have a script that, among other things, loads files with variable file names corresponding to dates. It can load dates within the last 7 days fine, however, I need it to load dates past that.
The script will be run on Friday mornings, and I need it to pull the entire week, plus entire previous week. Currently, it will pull the previous Friday (7 days ago) up through the previous day (Thursday).
What I need is the correct code to get it to pull last Monday through last Thursday.
The code to pull last Monday is below. I have tried changing Date - 1 to Date - 2, but that is not right. I know that vbMonday is supposed to correspond to a date within the last 7 days (if I understand correctly. Probably a simple thing I am missing, but no option seems to work.
(FYI all variables are declared, just omitted so it is easier to see what is happening)
LastMondayDate = Format(Date - (Weekday(Date - 1, vbMonday)), "m.d.yy")
fullFileNameLastMonday = strFilePath & LastMondayDate & ".xls"
If Dir(fullFileNameLastMonday) = "" Then
MsgBox "File for last Monday doesn't exist!"
GoTo ExitLastMonday
End If
Set wbkLastMonday = Workbooks.Open(fullFileNameLastMonday, False, True)
.......Do stuff.......
wbkLastMonday.Close SaveChanges:=False
ExitLastMonday:

Format(DateAdd("d",-11,Date),"m.d.yy").