Scott Huish
MrExcel MVP
- Joined
- Mar 17, 2004
- Messages
- 20,709
- Office Version
- 365
- Platform
- Windows
Hi, I have the following code.
The code completely stops if it successfully opens the workbook. No error, it just opens the workbook and then nothing else happens.
I have put in a checkpoint in the code to see if it actually gets that far and it only continues the code if the file did not exist.
Column A does contain valid dates in the workbook this code is running from. Any ideas?
The code completely stops if it successfully opens the workbook. No error, it just opens the workbook and then nothing else happens.
I have put in a checkpoint in the code to see if it actually gets that far and it only continues the code if the file did not exist.
Column A does contain valid dates in the workbook this code is running from. Any ideas?
Code:
Sub GetPressRun()
On Error Resume Next
Dim fp As String, cf As String, fn As String, dt As Date
Dim li As Range
Set li = Cells(ActiveCell.Row, 1)
dt = li
fp = "J:\Paper Sections\pressrun\"
fn = "Run Sheet (" & Format(dt, "m-d-yyyy") & ").xls"
If Dir(fp & fn) <> "" Then
Workbooks.Open fp & fn
Else
MsgBox "Press Run for date " & dt & " does not exist", vbExclamation
Exit Sub
End If
'Checkpoint #1
cf = ActiveWorkbook.Name
MsgBox cf
With Workbooks(fn).Sheets(1)
li.Offset(, 1) = .Range("E34")
li.Offset(, 4) = .Range("E25")
li.Offset(, 12) = .Range("E29") + .Range("E30")
End With
Workbooks(fn).Close False
End Sub