I have the following with statement that imports data from an external text file in a particular folder:
With Selection.QueryTable
.Connection = _
"TEXT;G:\pw587\L_Band_Status\MaxCallData\L_Factor_" & Year & "_0" & Month & "_" & Day & "_statistics.dat"
.TextFilePlatform = 437
.TextFileStartRow = 3333
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
I have this code within a for loop that increments the year, month, and day (shown in red above) each time through the for loop. I would like to know how to exit the macro if the file specified above in blue does not exist in the folder (shown in green).
Bookmarks