+ Reply to Thread
Results 1 to 13 of 13

Import Multiple Text Files into Excel - for beginners

  1. #1
    Registered User
    Join Date
    08-20-2012
    Location
    Chiang Mai, Thailand
    MS-Off Ver
    Excel 2007
    Posts
    3

    Import Multiple Text Files into Excel - for beginners

    I need some hand holding please. Zero experiences with VBA - step by step appreciated by me and the hordes of newbies...

    I need to import multiple text files into an Excel spreadsheet.

    the files are simple text, single line, single column no parsing needed.

    I want to import multiple files into a column in a worksheet

    folder = /filefolder/
    files = textfile-01.txt
    textfile-02.txt through textfile-250.txt

    I want textfile-01.txt to be in C1
    I want textfile-02.txt to be in C2 etc.

    I got as far as ALT+F11 opens VBA editor....

    thanks in advance

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,124

    Re: Import Multiple Text Files into Excel - for beginners

    Look at this article.
    David
    (*) Reputation points appreciated.

  3. #3
    Forum Guru tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Import Multiple Text Files into Excel - for beginners

    rapidasia,

    Welcome to the forum!
    Here is some commented code you can use to import text files:
    Please Login or Register  to view this content.


    How to use a macro:
    1. Make a copy of the workbook the macro will be run on
      • Always run new code on a workbook copy, just in case the code doesn't run smoothly
      • This is especially true of any code that deletes anything
    2. In the copied workbook, press ALT+F11 to open the Visual Basic Editor
    3. Insert | Module
    4. Copy the provided code and paste into the module
    5. Close the Visual Basic Editor
    6. In Excel, press ALT+F8 to bring up the list of available macros to run
    7. Double-click the desired macro (I named this one ImportTextFilesMacro_rapidasia)
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    08-20-2012
    Location
    Chiang Mai, Thailand
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Import Multiple Text Files into Excel - for beginners

    Wow - what a great forum and participants. Thank you, info is golden.

  5. #5
    Forum Contributor CheshireCat's Avatar
    Join Date
    10-11-2011
    Location
    Victoria, Canada
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    258

    Re: Import Multiple Text Files into Excel - for beginners

    Cross-posted at XLGuru
    Docendo discimus.

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Import Multiple Text Files into Excel - for beginners

    Thanks CheshireCat

    Hello rapidasia, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and make the necessary change. Thanks.

    I'm afraid your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  7. #7
    Registered User
    Join Date
    08-20-2012
    Location
    Chiang Mai, Thailand
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Import Multiple Text Files into Excel - for beginners

    Thanks for the help on this forum. I do understand the issue with cross posting, and now that I have found a reliable and helpful forum I will never do that again.

    You do have to understand however, that the reason many people cross post on multiple forums -- is that they don't get answers, at all or in a timely manner.

    sort of a catch-22 -- post too much and more energy is spent on correcting you than answering (on another forum I posted a cross-reference link and got blasted for it !) -- don't post on multiple forums and wait for a response that may never come.

    I will edit and add cross-references,

    thanks again for the help

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Import Multiple Text Files into Excel - for beginners

    You do have to understand however, that the reason many people cross post on multiple forums -- is that they don't get answers, at all or in a timely manner.
    We absolutely understand that, which is why we ask that you simply tell us by posting a link so that potential responders can check the link before responding. And there's no Catch 22 if you check the forum rules ahead of time to see what is and isn't allowed.

    Now, based on your previous post, it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  9. #9
    Registered User
    Join Date
    04-29-2013
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: Import Multiple Text Files into Excel - for beginners

    Quote Originally Posted by tigeravatar View Post
    rapidasia,

    Welcome to the forum!
    Here is some commented code you can use to import text files:
    Please Login or Register  to view this content.


    How to use a macro:
    1. Make a copy of the workbook the macro will be run on
      • Always run new code on a workbook copy, just in case the code doesn't run smoothly
      • This is especially true of any code that deletes anything
    2. In the copied workbook, press ALT+F11 to open the Visual Basic Editor
    3. Insert | Module
    4. Copy the provided code and paste into the module
    5. Close the Visual Basic Editor
    6. In Excel, press ALT+F8 to bring up the list of available macros to run
    7. Double-click the desired macro (I named this one ImportTextFilesMacro_rapidasia)
    Hi i'm trying to import multiple text files, however my files are of multiple lines, varying from 1 line to 200 lines. I need a macro to bring these in for me. Any help appriciated.

  10. #10
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,164

    Re: Import Multiple Text Files into Excel - for beginners

    Toxicca,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  11. #11
    Registered User
    Join Date
    04-29-2013
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: Import Multiple Text Files into Excel - for beginners

    Quote Originally Posted by arlu1201 View Post
    Toxicca,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    Sorry, i didn't realise. This thread is exactly what i needed just multi line so i thought would be ok to use same thread. I will start a new thread.

    Sorry again

  12. #12
    Registered User
    Join Date
    09-04-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Import Multiple Text Files into Excel - for beginners

    Hi RapidASiA
    i copy paste your code but it gives me error as "Run Time error - 1004
    Application defined or object defined error .
    The error is due to the below code
    If TextIndex > 0 Then Range("C1").Resize(TextIndex).Value = Application.Transpose(arrText)

    When i press END instead of Debug in the VBA message box i get an error as "OUT of Memory "

    I know this thread is very old ..but i sincerely request your help .

  13. #13
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    11,971

    Re: Import Multiple Text Files into Excel - for beginners

    @sumu
    Unfortunately your post does not comply with Rule 2 of our Forum RULES.

    Please do not resurrect old threads. Further, do not post your question in the thread someone else has started - this is known as thread hijacking and is against the Forum Rules.
    Always start your own thread and, if it helps to clarify your needs, provide a link back to other threads.

    I suggest you take the time to read the Forum Rules so that you can avoid infractions that will impact your posting privileges.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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