+ Reply to Thread
Results 1 to 3 of 3

Insert External Data

  1. #1
    Registered User
    Join Date
    03-31-2008
    Posts
    8

    Insert External Data

    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).

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,936
    Try:
    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    03-31-2008
    Posts
    8

    Thanks

    Thanks that did it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1