Dummy Excel
Well-known Member
- Joined
- Sep 21, 2005
- Messages
- 1,004
- Office Version
- 2019
- 2010
- 2007
- Platform
- Windows
Hi All,
I have a question - I have a report that is run within the first week of the new month which the data is for the previous month.
I need to open the previous month report to get the running history. All the filenames are the same except it has the month and year at the end of it eg "xxx Monthly Report Jun 08.xls"
my code so far is:
How can I change the bold so that it picks up the previous month/year to the current month/year? hope that makes sense?
thanks
Sam
I have a question - I have a report that is run within the first week of the new month which the data is for the previous month.
I need to open the previous month report to get the running history. All the filenames are the same except it has the month and year at the end of it eg "xxx Monthly Report Jun 08.xls"
my code so far is:
Rich (BB code):
Sub Example()
Workbooks.Open GetFile("S:\UW&H OF Reports\")
End Sub
Function GetFile(Path As String) As String
Dim f As Object, d As Date
If Customer = "xxxx" Or Customer = "xxx xxx" Then f = "xxx Monthly Report Jun 08.xls"
For Each f In CreateObject("Scripting.FileSystemObject").GetFolder(Path).Files
If d < f.DateLastModified Then
d = f.DateLastModified
GetFile = f.Path
End If
Next
End Function
thanks
Sam