Hi Ken,
If I understand you correctly, you would like to import data out of a text file, into, for instance Excel.
Here is what I would do.
-Create a new Excel file (I assume using Excel isn't a problem).
-Click on the "record macro" button, and simply do the following: select Data on Toolbar>Import External Data>Import data.
-Select your .txt file and click Open. Follow steps within wizard...
-When done, click on "stop recording macro" button.
-In the VBA screen you should be able to see the code of your macro. Adjust if necessary (VBE opens with Alt+F11).
Here is an example of VBA code created with recording a macro...(NOTE: place the right path and filename in the subroutine here below if using this technique)
Sub Macro1()
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\yourdirectory\yourtextfilename.txt" _
, Destination:=Range("A1"))
.Name = "data"
.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
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Hope this helps...
|