Import Text File into Spreadsheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi:

I'm trying to create a macro that will import a tab delimited text file into
a spreadsheet.

Any help will be greatly appreciated.

Thanks
 
Turn on the macro recorder while you open the text file, using the Text
Import Wizard.
 
The best way to to do what you want is to record a macro while manually doing
the operation. I did that and eliminate some unecessary lines of code. Here
is what I got

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 10/3/2007 by Joel
'
'
With ActiveSheet.QueryTables. _
Add(Connection:="TEXT;C:\TEMP\abc.txt", _
Destination:=Range("A1"))
.Name = "abc"
.TextFileParseType = xlDelimited
.TextFileTabDelimiter = True
.Refresh BackgroundQuery:=False
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top