Results 1 to 4 of 4

Import multiple text files to 1 column

Threaded View

  1. #1
    Registered User
    Join Date
    05-07-2012
    Location
    USA, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    11

    Import multiple text files to 1 column

    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
    Last edited by vbarookie_1000; 05-07-2012 at 01:44 PM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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