Import multiple text files to 1 column
Hello All,
I have been using the following code to import text files into 1 excel sheet. This code takes file 1 and imports it into Column A. The next file it puts in column B. the problem is I need code to all the txt files into column A? is there a way to make this macro import everything into 1 column?
excel Version = 2007
Sub Opentext()
Dim fpath As String
Dim fname As Variant
fpath = "C:\logtocap"
fname = Application.GetOpenFilename _
(filefilter:="TXT Files (*.*), *.txt", MultiSelect:=True)
For X = LBound(fname) To UBound(fname)
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
& fname(X), Destination:=Cells(1, X))
.SaveData = True
.TextFilePlatform = 437
.Refresh BackgroundQuery:=False
End With
Next X
End Sub
Bookmarks