Sub import Macro

Sub import()
'
' import Macro to import a text file into Excel
'
'First, it deletes anything in columns A:O

    Columns("A:O").Select
    Selection.QueryTable.Delete
    Selection.Clear
    Range("A1").Select 
'selects the area to start import
'imports data from the same foder as the excel file by using the relative reference path below
'make sure to name the text file as specified below, in this case it's "import.txt"

        With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & ThisWorkbook.Path & "\import.txt", Destination:=Range("A1"))
        .Name = "import_1"
        .FieldNames =
True
        .RowNumbers =
False
        .FillAdjacentFormulas =
False
        .PreserveFormatting =
True
        .RefreshOnFileOpen =
False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword =
False
        .SaveData = True
        .AdjustColumnWidth =
True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh =
False
        .TextFilePlatform = 437
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter =
False
        .TextFileTabDelimiter =
True
        .TextFileSemicolonDelimiter =
False
        .TextFileCommaDelimiter =
False
        .TextFileSpaceDelimiter =
False
        .TextFileOtherDelimiter = "|"
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
        .TextFileTrailingMinusNumbers =
True
        .Refresh BackgroundQuery:=
False
End With
End Sub


Comments

No comments yet
*Name:
Email:
Notify me about new comments on this page
Hide my email
*Text:
 
 
Comments Powered by: Scriptsmill Comments Script
Web designed by: Jose Guevara Balboa © 2015Comments Admin