+ Reply to Thread
Results 1 to 6 of 6

Loop through all txt files and paste as separate columns in excel

  1. #1
    Forum Contributor
    Join Date
    02-13-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    217

    Loop through all txt files and paste as separate columns in excel

    I have a folder with a lot of files of the form: defects_*.txt

    Assuming the path to the directory containing these files is C:/Path, how can I load just the second column of these txt files into excel?

    So column A would be the 2nd column of defects_002.txt, column B would be the 2nd column of defects_005.txt, etc (no constant increment). Can VBA do this, or do I need to use something else?

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Loop through all txt files and paste as separate columns in excel

    Hi bjcowen,

    This is a problem for Power Query which is an Add-In to Excel 2010.

    Read about it at:

    http://excelunplugged.com/2015/02/10...n-power-query/

    The beauty of Power Query is, once you have built an Excel file using PQ, you simply add more files in your folder and run it again. It will do it again using all the old and new files in that folder.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    02-13-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: Loop through all txt files and paste as separate columns in excel

    great just downloaded it, and now my excel version, which i havent had issues with for years, is giving me all sorts of errors. I feel like you just sabotaged my excel version. I keeping getting Microsoft .Net Framework errors
    Last edited by bjcowen9000; 09-19-2018 at 09:09 PM.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Loop through all txt files and paste as separate columns in excel

    Hey - Bad news!!!

    Did you download and install from this site?

    https://www.microsoft.com/en-us/down....aspx?id=39379

    Read the "System Requirements" on the link above and see if I screwed things up for you. I hope not.

    I'm using Office 365 for $10/month and it upgrades some features each month. It also has Power Query built in but is called Get & Transform. If you don't have a compatible old version then I'd suggest upgrading to the latest.

    Sorry you are having this problem and getting errors.

    Here is an answer on Reddit that suggests a possible solution.

    https://www.reddit.com/r/excel/comme...uery_download/
    I think you need to restart Excel and Reboot your computer before anything else. I'd also insure I had the Windows upgrade if you are using Windows 10. That is on the Windows Settings - Updates and Security.

  5. #5
    Forum Contributor
    Join Date
    02-13-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: Loop through all txt files and paste as separate columns in excel

    I have windows 8 and excel 2013. can vba do what I need?
    Last edited by bjcowen9000; 09-19-2018 at 10:52 PM.

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: Loop through all txt files and paste as separate columns in excel

    Note this has been cross-posted here
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

+ 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. loop through files find columns and copy/paste them as columns in master workbook
    By Michal1111 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2018, 10:40 PM
  2. [SOLVED] VBA Code to copy specific contents from 2 text files to separate excel columns
    By Miteshkg in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 02-22-2016, 03:31 AM
  3. [SOLVED] copy columns from individual files and paste in another excel file
    By kuntalnr in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-04-2015, 10:18 AM
  4. Loop through an existing filter and copy and paste content into separate workbook
    By moyay4 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-21-2014, 11:39 AM
  5. Replies: 2
    Last Post: 12-25-2013, 03:47 PM
  6. Open Separate Excel Files in Separate Windows
    By JTWood in forum Excel General
    Replies: 3
    Last Post: 05-07-2006, 05:18 PM
  7. Open Excel files in separate sessions, not just separate windows?
    By Bob at Dexia Design in forum Excel General
    Replies: 1
    Last Post: 10-18-2005, 01:05 PM

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