+ Reply to Thread
Results 1 to 3 of 3

Import Multiple Text Files from a Folder using VBA

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    New Mexico
    MS-Off Ver
    Excel 2007
    Posts
    10

    Import Multiple Text Files from a Folder using VBA

    I have been searching for an answer online, and I am getting sporadic results.

    I would like to bring in the data from about 8 text files (actually .rpt files) located in a folder on my computer. I would like to have a VBA code that will loop through the folder, import the data from the files and insert them all in the same worksheet -named 'DATA' in succeeding columns. With this data in place, I can run a macro that I have already built. At this point in time, I have to manually open the file in word, run a data-selection macro, go back to excel and run the macro there.

    Any help or direction would be greatly appreciated. I will use this code continually, with varying number of files, so it should have the flexibility to import 8 or import 3.

    Adam

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Import Multiple Text Files from a Folder using VBA

    attach please a sample txt file and a xls file with desired result
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Import Multiple Text Files from a Folder using VBA

    Hi, Adam ,

    the basic code for doing so might look like this (you may need to alter the separator to suit your needs as I picked semicolon here):
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Auto import data from all text files in a folder (VBA)
    By anto80mtl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2013, 12:34 PM
  2. Replies: 0
    Last Post: 08-10-2012, 02:32 AM
  3. How to import all text files (column wise) from a folder?
    By Amit1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2012, 02:25 AM
  4. Import multiple .csv files from folder that updates each day
    By jnix4861 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2008, 10:32 PM
  5. import all text files in folder
    By shoshanako in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2008, 10:01 AM

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