Results 1 to 5 of 5

Help to import multiple text files to worksheets in a excel workbook

Threaded View

  1. #1
    Registered User
    Join Date
    08-22-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Help to import multiple text files to worksheets in a excel workbook

    Hi

    I have no programming background but have managed to record a macro to import a single text file into a worksheet.

    The code is below but
        Workbooks.OpenText FileName:="W:\xyz\abc\output.txt.server1", Origin _
            :=xlMSDOS, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0 _
            , 1), Array(9, 1), Array(15, 1), Array(22, 1), Array(23, 1), Array(29, 1), Array(35, 1), _
            Array(47, 1)), TrailingMinusNumbers:=True

    Can someone show me how to amend this so that the macro does a loop and picks up all the text files under location W:\xyz\abc\

    I did try code like below but i didnt work
     Do While FileName <> ""
            Workbooks.OpenText FileName:="W:\xyz\abc\" & strFileNameHere, _

    Also when the save is done to the worksheet, I would like each worksheet within the spreadsheet to be called the name of the text file that has been run in? can someone please provide the code on how to do this?

    Thanks
    Last edited by Leith Ross; 08-22-2011 at 11:29 AM. Reason: Added Code Tags

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