+ Reply to Thread
Results 1 to 3 of 3

Adding a line of text and removing a line of text from txt file?

  1. #1
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    786

    Adding a line of text and removing a line of text from txt file?

    C:\Users\Mike\My_Documents\MostRecentActivities.txt

    One line for each activity.

    If the text file does not exist (or carelessly deleted), then create the text file and add a new line as first activity, e.g. "Hello world, " & Format(Now(), "hh:mm:ss AM/PM mmm, dd, yyyy)"

    If the text file is exist and there are less or equal to 99 lines of text, then add a line as new activity.

    If there are 100 lines or more, remove oldest activity, then add the new activity. So if there are already 100 lines, remove first line, then add a new line at the bottom (assuming that activity is from oldest to newest; however, it is also okay to go from newest to oldest). In this case, it will never exceed 100 lines.

    Some scratch, not all the code for what I want to do. No idea how to get number of lines in text file, no idea how to delete a line from the top.

    Please Login or Register  to view this content.
    Last edited by VAer; 11-01-2024 at 08:58 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    389

    Re: Adding a line of text and removing a line of text from txt file?

    Dear try this

    Please Login or Register  to view this content.
    its getting any error. kindly attached the sample to my understanding
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Mark Thread as Solved...

  3. #3
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    786

    Re: Adding a line of text and removing a line of text from txt file?

    Quote Originally Posted by sudbhavani View Post
    Dear try this

    Please Login or Register  to view this content.
    its getting any error. kindly attached the sample to my understanding
    Thank you very much, it works great.

+ 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. Error Reading Text File Line By Line
    By bennyys in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2018, 05:28 AM
  2. Adding same text at the end of each line on external text files
    By Loski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2016, 05:49 AM
  3. [SOLVED] Reading line by line data from Text file
    By wyldencl in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-18-2015, 10:09 PM
  4. Removing partial text in a line
    By Fugly in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-24-2013, 08:45 AM
  5. analyzing text file line by line
    By HarryKlein in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-16-2011, 12:20 PM
  6. Reading a text file line by line-How do I open the text file with VBA
    By stressman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-16-2005, 12:29 AM
  7. [SOLVED] Reading a text file line by line
    By Foss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2005, 12:06 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