+ Reply to Thread
Results 1 to 10 of 10

Fast Efficient Editing of Text Files

  1. #1
    Registered User
    Join Date
    10-24-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Fast Efficient Editing of Text Files

    I have to open text files and edit them to remove rows of data, leaving only 6 header rows and the last row.

    I also need to apply a multiplier to the values in the last row. The multiplier is held in another part of the Excel file and varies depending on which file I am editing.

    This is part of a bigger process.

    The challenge I have is that this must be done for multiple files in a very short time period, so I am looking for the quickest way of performing this task.

    I have looked at using FSO but my skills are not very strong in that area.

    Can you provide a better solution than the one I am using?

    Also, I find the Displayalerts and Close Workbook functionality is inconsistent - sometimes dialogue boxes still appear. Can you provide some hints in this area?

    Files attached:
    A cut down version of the Excel workbook
    Before and after examples of the text file

    Please Login or Register  to view this content.
    Thanks!
    Attached Files Attached Files
    Last edited by labrooy; 07-27-2016 at 01:14 AM.

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

    Re: Fast Efficient Editing of Text Files

    Hi Labrooy,

    This sounds like a job for Power Query that is a newer tool in Excel 2010 and newer. It pulls in lots of different types of files and can do things like keep the top 6 rows and also use filenames or other parts of the workbook to merge in the data. See if you can upgrade and if it sounds like a fit for your problem. It is called Get & Transform in Excel 2016 but was called Power Query before that.

    http://blogs.adatis.co.uk/dan%20evan...in-Power-Query or
    http://www.excelguru.ca/blog/2014/12...s-a-text-file/
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    10-24-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Fast Efficient Editing of Text Files

    Thanks MarvinP, I am now using Excel 2010 (just updated my profile) so will look into it. The Production version sits on a corporate server so it may take some time to implement Power Query.

    Any other responses in the meantime are most welcome.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Fast Efficient Editing of Text Files

    I can only see the difference between "Sample file.txt" and "Sample file end.txt" is the title...
    [LoadSurvey] and [Survey]

    Am I missing something?

  5. #5
    Registered User
    Join Date
    10-24-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Fast Efficient Editing of Text Files

    Sorry jindon, I have removed the "Sample file.txt" and added "Sample file start.txt"

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Fast Efficient Editing of Text Files

    This code is only for testing purpose.
    See if the code generates the new text file.
    Please Login or Register  to view this content.
    Last edited by jindon; 07-27-2016 at 02:04 AM.

  7. #7
    Registered User
    Join Date
    10-24-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Fast Efficient Editing of Text Files

    Thanks jindon, yes the code does produce a file and the file contents are correct.
    I have updated 3 lines to meet my needs and incorporated the code into my macro.

    Now I just need to analyse it to understand the code better!

  8. #8
    Registered User
    Join Date
    10-24-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Fast Efficient Editing of Text Files

    Hi jindon,
    I have tested this more thoroughly and sometimes it does not produce the correct output file. It is failing the If statement
    Please Login or Register  to view this content.
    It then skips that section, which results in the mlt value not being applied to the output file.

    Attached are sample files where the code does not produce the correct output.

    Here is the code I am using - 2 lines have been modified from your code.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Fast Efficient Editing of Text Files

    Try change 2nd pattern to
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    10-24-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Fast Efficient Editing of Text Files

    Thanks jindon, working now.

+ 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. VBA to read text file fast and efficient
    By DaveNUFC in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-03-2016, 11:48 PM
  2. Automation: fast I/O XLS files from Delphi: Direct access?
    By mot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2015, 01:55 AM
  3. Replies: 1
    Last Post: 10-21-2010, 06:26 AM
  4. Editing Excel files in text editor (vim)
    By odicenta in forum Excel General
    Replies: 3
    Last Post: 01-19-2009, 12:25 PM
  5. recently used files, more efficient
    By Patricia Shannon in forum Excel General
    Replies: 0
    Last Post: 04-04-2006, 06:35 PM
  6. Close Files Fast
    By ch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2005, 01:59 PM
  7. [SOLVED] Fast Find possibly replacing .xls files
    By Raul in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2005, 04:06 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