tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have a macro that opens a file and pulls in data,
I would like to add a bit of code that checks that file exists, if not exit sub
please help if you can
Thanks
Tony
Here my code:
I have a macro that opens a file and pulls in data,
I would like to add a bit of code that checks that file exists, if not exit sub
please help if you can
Thanks
Tony
Here my code:
VBA Code:
Sub Open_Dell()
With Workbooks.Open(ThisWorkbook.Path & "\Dell Notebooks.xlsx", UpdateLinks:=0)
With .Sheets("Layout")
.Range("A2:D" & .Range("A" & Rows.Count).End(xlUp).Row).Copy
Lr1 = ThisWorkbook.Sheets("Price Lists").Cells(Rows.Count, "A").End(xlUp).Row + 2
ThisWorkbook.Sheets("Price Lists").Range("A" & Lr1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
.Close False
End With
End Sub