i am getting error End without with statement on my code. Basically I want to check to see if a file exist, if it does not then msgbox if it does then open it, copy a range, and paste the range to a destination range. I also want to be able to do it for multiple files.
Sub test()
Dim WbookCheck As Workbook
Dim filepaths As String
On Error Resume Next
Set WbookCheck = Workbooks("LL-AD-ARROW.xls")
On Error GoTo 0
If WbookCheck Is Nothing Then 'not open....
filepaths = "c:\Disti-Master\Data\LL-AD-ARROW.xls"
If Dir(filepaths) = "" Then
MsgBox "File is missing"
Exit Sub
Else
'file exists - open it
Set WbookCheck = Workbooks.Open(filepaths)
Cells.Select
Sheets("Sheet1").Range("B5").Activate
Selection.Copy
Windows("WW Disti Weekly Q116_Master.xlsm").Worksheets("Update").Range("D3").Activate
Selection.PasteSpecial xlPasteValues
End If
End With
End Sub