Good morning everyone!
I am working on some code that extracts a file with the name EODVAL_11.16.05.xls
The thing is, the file's date changes everyday and i would like to have it open if not already opened and that way i can extract the current day information.
I have the code below but i dont think i have the file path placed in the right area. I took this code off of here and changed it up a little but I kinda ran into a wall right now. If anyone wants to help...i would be most appreciative.
Private Sub Workbook_Open()
Dim x As Workbook
Dim c As Long
Const TestFilename As String = "EODVAL_ & c.xls"
c = DateAdd("d", -1, today())
On Error Resume Next
Set x = Workbooks(TestFilename)
On Error GoTo 0
If x Is Nothing Then
On Error Resume Next
Set x = Workbooks.Open(ThisWorkbook.R:\MidOffice\Data\Valuation\Daily Validation\EOD VAL, 0)
On Error GoTo 0
If x Is Nothing Then
MsgBox TestFilename & " not open and not found"
Exit Sub
End If
End If
ThisWorkbook.Windows(1).Activate
End Sub
End Sub
I am working on some code that extracts a file with the name EODVAL_11.16.05.xls
The thing is, the file's date changes everyday and i would like to have it open if not already opened and that way i can extract the current day information.
I have the code below but i dont think i have the file path placed in the right area. I took this code off of here and changed it up a little but I kinda ran into a wall right now. If anyone wants to help...i would be most appreciative.
Private Sub Workbook_Open()
Dim x As Workbook
Dim c As Long
Const TestFilename As String = "EODVAL_ & c.xls"
c = DateAdd("d", -1, today())
On Error Resume Next
Set x = Workbooks(TestFilename)
On Error GoTo 0
If x Is Nothing Then
On Error Resume Next
Set x = Workbooks.Open(ThisWorkbook.R:\MidOffice\Data\Valuation\Daily Validation\EOD VAL, 0)
On Error GoTo 0
If x Is Nothing Then
MsgBox TestFilename & " not open and not found"
Exit Sub
End If
End If
ThisWorkbook.Windows(1).Activate
End Sub
End Sub