Small Paul
Board Regular
- Joined
- Jun 28, 2018
- Messages
- 118
Hi
I have a number of files saved each day, with either the current date or previous working day date in the filename.
To open yesterday's workbook is now no problem:
However, on a Monday, I need Friday's file which is "-3".
What is the logic to say 'if yesterday's does not exist, open another'?
At the moment, I have the following snippet of code.
Many thanks
Small Paul.
I have a number of files saved each day, with either the current date or previous working day date in the filename.
To open yesterday's workbook is now no problem:
Code:
Workbooks.Open Filename:= _
"Z:\Secondary Market\Pricing\Daily Index Levels\Index Levels " & Format(Now() - 1, "yyyy-mm-dd") & ".csv"
However, on a Monday, I need Friday's file which is "-3".
What is the logic to say 'if yesterday's does not exist, open another'?
At the moment, I have the following snippet of code.
Code:
Workbooks.Open Filename:= _ "Z:\Secondary Market\Pricing\Daily Index Levels\Index Levels " & Format(Now() - 1, "yyyy-mm-dd") & ".csv"
If wb Is Nothing Then
Workbooks.Open Filename:= _
"Z:\Secondary Market\Pricing\Daily Index Levels\Index Levels " & Format(Now() - 3, "yyyy-mm-dd") & ".csv"
End If
Many thanks
Small Paul.