+ Reply to Thread
Results 1 to 4 of 4

Adding same text at the end of each line on external text files

  1. #1
    Registered User
    Join Date
    05-10-2015
    Location
    France
    MS-Off Ver
    10
    Posts
    58

    Adding same text at the end of each line on external text files

    Hello,
    I can read external text files. I can create & write these files but I have a hard time figuring out how to add a specific text such as " Level_1" at the end of each line of an external file in order to differentiate those lines when I read all those external files all together. Right now, I have to add those " Level_1" text by hand with copy & paste. OK when few lines, impossible with plenty.
    Thank so much for helping.

  2. #2
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: Adding same text at the end of each line on external text files

    Use Line Input to read line by line, outputting to a new file with the additional text appended.
    Please Login or Register  to view this content.
    One minor change needed - it will throw an error if the temporary or backup files already exist (.TMP or.BAK), got to leave sometihng for you to do so you can claim it as yours.

    There are probably faster ways to do this, but that is about the easiest to understand.
    Last edited by grimes0332; 02-11-2016 at 04:57 AM.

  3. #3
    Registered User
    Join Date
    05-10-2015
    Location
    France
    MS-Off Ver
    10
    Posts
    58

    Re: Adding same text at the end of each line on external text files

    great, thanks

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Adding same text at the end of each line on external text files

    Quote Originally Posted by Loski View Post
    I can read external text files. I can create & write these files but I have a hard time figuring out how to add a specific text such as " Level_1" at the end of each line of an external file in order to differentiate those lines when I read all those external files all together. Right now, I have to add those " Level_1" text by hand with copy & paste. OK when few lines, impossible with plenty.
    The following macro lets you select the file to alter, then it asks you what text to place at the end of each line and then it overwrites the original file with this modified text. I also put in some code to warn you if it looks like you are trying to add the same text that has already been added before.
    Please Login or Register  to view this content.

+ 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. read a line from external text files on a random basis
    By Loski in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-14-2015, 11:44 AM
  2. [SOLVED] IMPORTING TEXT FILES TO EXCEL - Multiple Multi-line text files, each in a new column
    By wrenchfry in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-23-2014, 08:37 PM
  3. problem with macro to pull data from external text files
    By codelphi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-19-2014, 05:44 PM
  4. IMPORTING TEXT FILES TO EXCELL - Multiple Multi line text files
    By Toxicca in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-12-2014, 09:56 AM
  5. Using external text file to assign VBA variables for multiple excel files
    By evancharles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2013, 05:30 AM
  6. Search text of external files and import
    By flaterp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2005, 01:50 PM
  7. RE: Search text of external files and import
    By TomHinkle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2005, 12:25 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