+ Reply to Thread
Results 1 to 2 of 2

Import and format multiple .txt files from one folder into excel

Hybrid View

  1. #1
    Registered User
    Join Date
    07-29-2013
    Location
    San Francisco, California
    MS-Off Ver
    2007
    Posts
    4

    Import and format multiple .txt files from one folder into excel

    Hello Everyone!

    first post here and really digging all of the information. I am very new to marcos and am excited to learn as much as I can looking through the forums. I have a question.

    Is it possible to set up a marco so that it will open every .txt file in a folder, format it using fixed width and put it all in a workbook?

    Any help would be greatly appreciated.

    Thanks!

    Nick

  2. #2
    Registered User
    Join Date
    07-29-2013
    Location
    San Francisco, California
    MS-Off Ver
    2007
    Posts
    4

    Re: Import and format multiple .txt files from one folder into excel

    I've tried to use the macro recorder, but not sure how to loop for all files within a directory. Here's what the recorder says opening two of the files..

    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    Workbooks.OpenText Filename:= _
    "C:\Users\nchristie\Documents\Data\New folder\Complete Transaction Journal (CU130) - 06_01_2013.txt" _
    , Origin:=437, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
    Array(0, 1), Array(2, 1), Array(6, 1), Array(11, 1), Array(18, 1), Array(23, 1), Array(32, 1 _
    ), Array(44, 1), Array(92, 1), Array(104, 1), Array(127, 1), Array(129, 1)), _
    TrailingMinusNumbers:=True
    Workbooks.OpenText Filename:= _
    "C:\Users\nchristie\Documents\Data\New folder\Complete Transaction Journal (CU130) - 06_03_2013.txt" _
    , Origin:=437, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
    Array(0, 1), Array(3, 1), Array(6, 1), Array(18, 1), Array(23, 1), Array(33, 1), Array(44, 1 _
    ), Array(65, 1), Array(98, 1), Array(100, 1), Array(103, 1), Array(120, 1)), _
    TrailingMinusNumbers:=True
    End Sub

+ 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. Replies: 2
    Last Post: 03-23-2013, 04:17 AM
  2. 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
  3. Replies: 1
    Last Post: 01-24-2006, 11:35 AM
  4. Replies: 1
    Last Post: 01-24-2006, 11:00 AM
  5. Replies: 1
    Last Post: 01-24-2006, 12:25 AM

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