+ Reply to Thread
Results 1 to 10 of 10

VBA to remove a certain string in a Text file.

  1. #1
    Registered User
    Join Date
    06-30-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    6

    VBA to remove a certain string in a Text file.

    Hi.

    Would like to seek help in removing the bold characters in my .txt file below.

    00012345678912345678912
    1234546
    123456
    12345
    00012345678912345678950041
    1234546
    123456
    12345
    00032345678912345678901510
    1234546
    123456
    12345
    000423456789123456789540
    1234546
    123456
    123450
    00071234567891234567890520
    1234546
    123456
    12345
    00071234567891234567890510
    1234546
    123456
    12345
    000612345678912345678904505
    1234546
    123456
    12345
    000612345678912345678907451
    1234546
    123456
    12345
    00011234567891234567890450121
    1234546
    123456
    12345

    I want to remove the 4th digit of the 1st line and every 5th line from the last modified line.

    Thanks in advance.

    Im want to learn VBA, are there any links of VBA easy tutorials?

  2. #2
    Forum Contributor
    Join Date
    05-06-2016
    Location
    Cluj, Romania
    MS-Off Ver
    2007-2010
    Posts
    220

    Re: VBA to remove a certain string in a Text file.

    Hi,

    how distinguish modified text from the unaltered text?
    Think about that.

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

    Re: VBA to remove a certain string in a Text file.

    Try
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-30-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    6
    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.
    Thanks... This is exactly what i needed..

    But if i wanted to remove 1 more line just like below?

    00012345678912345678912
    1234546
    123456
    00012345678912345678950041
    1234546
    123456
    00032345678912345678901510
    1234546
    123456
    000423456789123456789540
    1234546
    123456
    00071234567891234567890520
    1234546
    123456
    00071234567891234567890510
    1234546
    123456
    000612345678912345678904505
    1234546
    123456
    000612345678912345678907451
    1234546
    123456
    00011234567891234567890450121
    1234546
    12345

    Still to remove the 4th digit of the 1st line and every 4th line from the last modified line.

  5. #5
    Registered User
    Join Date
    06-30-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    6
    Quote Originally Posted by TudyBTH View Post
    Hi,

    how distinguish modified text from the unaltered text?
    Think about that.
    A new txt file should be created, because the original data should still be retained.

    Thank you.

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

    Re: VBA to remove a certain string in a Text file.

    It doesn't matter every 4th or 5th line.
    It remove the 4th character from the lines that have more than 19 digits.

    Isn't that what you wanted?

  7. #7
    Registered User
    Join Date
    06-30-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    6
    Quote Originally Posted by jindon View Post
    It doesn't matter every 4th or 5th line.
    It remove the 4th character from the lines that have more than 19 digits.

    Isn't that what you wanted?
    Apologies, i have been unclear about this.. But sometimes the lines can have characters as long or as short as the other lines. I need to remove the 4th character in the 1st line, 4th line, 7th line, 10th line, 13th line.. and so on. Thank you.

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

    Re: VBA to remove a certain string in a Text file.

    Then adjust Step 3 (every 4th) as you require. e.g. 4 for every 5th.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-30-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    6

    Re: VBA to remove a certain string in a Text file.

    Exactly!... Thank you very much..

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

    Re: VBA to remove a certain string in a Text file.

    You are welcome and thanks for the rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. Replies: 2
    Last Post: 05-27-2016, 12:30 AM
  2. Replies: 8
    Last Post: 12-02-2013, 02:48 AM
  3. Replies: 2
    Last Post: 08-16-2013, 02:45 AM
  4. Remove text from a string
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2011, 09:00 AM
  5. remove text from string
    By crj510 in forum Excel General
    Replies: 6
    Last Post: 05-05-2011, 06:06 PM
  6. Replies: 1
    Last Post: 04-18-2005, 05:06 PM
  7. Replies: 1
    Last Post: 04-17-2005, 08:10 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