I've been working on this particular issue for about 5 hours and cannot seem to find the correct syntax. I have a command button that when clicked, launches a module. That module then calls ~30 other modules; all of which tap out to a shared drive and ingest data from other workbooks. I need to account for the fact that when this is run each month, not every file will be present in the shared drive. I've tried a couple variations of the underlying snippet, but this one seems to get me the closest. If the file is present, the code runs as expected. However, if the file isn't present, it's launching an error dialogue box at
VBA Code:
Set s = Workbooks.Open(fP & fN)
VBA Code:
Dim m As Workbook, s As Workbook
Dim mD As Worksheet, sD As Worksheet
Dim fP As String, fN As String, fE As String
Dim Hdr As Range, c As Range
Dim mDLR As Long, mNLR As Long, sDLR As Long
Set m = ThisWorkbook
Set mD = m.Sheets("New Data")
mDLR = mD.Range("A" & Rows.Count).End(xlUp).Row
fP = "C:\Users\Import Files\"
fN = "LMemo"
fN = Dir(fP & fN & "*.xlsx")
If Len((Dir(fP & fN))) < 1 Then GoTo MissingFile
Set s = Workbooks.Open(fP & fN) 'Error dialogue box is showing here.
'My code is here.
MissingFile:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub