+ Reply to Thread
Results 1 to 12 of 12

Help needed in importing a text file to excel

  1. #1
    Registered User
    Join Date
    04-19-2016
    Location
    Bangalore,India
    MS-Off Ver
    2013
    Posts
    34

    Help needed in importing a text file to excel

    Hi Friends,

    I have a list of paths in my excel sheet for the text files(.txt). I have to write a code that takes the path and open a new workbook and copies that text file into the new workbook and save it.

    Each text file should get copied into a separate sheets.
    Can anyone help me with this .?

    Thanks in advance.

  2. #2
    Forum Contributor kalbasiatka's Avatar
    Join Date
    02-27-2016
    Location
    Brest, Belarus
    MS-Off Ver
    2021
    Posts
    224

    Re: Help needed in importing a text file to excel

    Hi. It is necessary to see the text file and the result, save it in excel.
    To do it for me and help me it is 2 different things!
    Sorry for my english, blame Google translator

  3. #3
    Registered User
    Join Date
    04-19-2016
    Location
    Bangalore,India
    MS-Off Ver
    2013
    Posts
    34

    Re: Help needed in importing a text file to excel

    Hi kalbasiatka,

    Thanks for the reply . I have attached my a sample textfile .
    There will be similar files in the folder whose path will be present in the excel sheet.
    I need to import the complete data from the text files by opening a new excel and save it.
    One text file per sheet then i need to add next sheet to copy the next text file using vba.

    Can you please help me.
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help needed in importing a text file to excel

    Try recording a macro when you either open one of the text files via File>Open... or import it to a sheet using Data>From Text.

    Either should generate code that can be adapted to work with your list of files.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    04-19-2016
    Location
    Bangalore,India
    MS-Off Ver
    2013
    Posts
    34

    Re: Help needed in importing a text file to excel

    Hi Norie,
    Thanks for helping. I have got an idea to solve this.

    Thanks alot.

  6. #6
    Forum Contributor kalbasiatka's Avatar
    Join Date
    02-27-2016
    Location
    Brest, Belarus
    MS-Off Ver
    2021
    Posts
    224

    Re: Help needed in importing a text file to excel

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-19-2016
    Location
    Bangalore,India
    MS-Off Ver
    2013
    Posts
    34

    Re: Help needed in importing a text file to excel

    Hi kalbasiatka,

    Thanks for the reply. I tried this code this actally covert the text file into a excel file but i need to import all the text files into a new same workbook.

    Can you help me Please?

  8. #8
    Registered User
    Join Date
    04-19-2016
    Location
    Bangalore,India
    MS-Off Ver
    2013
    Posts
    34

    Re: Help needed in importing a text file to excel

    Hi Norie,
    I tried recording the macro as you suggested but while i am trying to run the macro by modifying the code i am getting an error "Run-time error 1004:"
    "Excel cannot find the text file ".

    This was the code when i recorded the macro i edited it according to my requirement .
    Please Login or Register  to view this content.


    Can you help me with this

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help needed in importing a text file to excel

    This is how you would incorporate the variable file in the code.
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor kalbasiatka's Avatar
    Join Date
    02-27-2016
    Location
    Brest, Belarus
    MS-Off Ver
    2021
    Posts
    224

    Re: Help needed in importing a text file to excel

    Collect all text files in a book
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    04-19-2016
    Location
    Bangalore,India
    MS-Off Ver
    2013
    Posts
    34

    Re: Help needed in importing a text file to excel

    Hi Norie,
    Thanks alot it works fine.Thanks for helping me
    Last edited by chandrup23; 07-17-2016 at 04:36 AM.

  12. #12
    Registered User
    Join Date
    04-19-2016
    Location
    Bangalore,India
    MS-Off Ver
    2013
    Posts
    34

    Re: Help needed in importing a text file to excel

    Hi kalbasiatka,
    Thanks alot for helping me.The code works fine.

+ 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. [SOLVED] importing text file into excel file using macro
    By ananthbulusu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2013, 04:08 PM
  2. Importing text file into excel
    By sentinela in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-02-2009, 04:20 PM
  3. Importing a text file into Excel
    By JibrilBenes in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 02-18-2009, 05:31 PM
  4. Importing text file into Excel
    By steadfast199 in forum Excel General
    Replies: 1
    Last Post: 01-27-2009, 01:16 PM
  5. importing text file to EXCEL
    By avveerkar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-21-2007, 03:25 PM
  6. Importing text file to Excel
    By zodiac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2006, 10:23 AM
  7. [SOLVED] Importing Text File into Excel
    By Martin in forum Excel General
    Replies: 1
    Last Post: 04-02-2006, 09:55 AM
  8. [SOLVED] Importing text file to excel
    By dany04 in forum Excel General
    Replies: 1
    Last Post: 11-08-2005, 09:15 PM

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