Consulting

Results 1 to 7 of 7

Thread: COUNTING

  1. #1
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location

    COUNTING

    hI

    i need help with macro to count numbers of lines in the
    text file and then delete line number 62 and then every line +60 lines

    thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    The code I gave you earlier showed you how to read a text file and output to another. Just add a counter and when you get to 62, don't write it. Then every 60 thereafter don't write.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    hi
    i want to ask another question regarding the same issue
    how can i prevent the copy of the next line after special value.
    i can manage with the searching of the value but the prevention i am stuck


    thanks.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What you need to do is open the file once as input, and a new file as output. Read each line of input and write to output. If you want to insert a line, just write it to output. If you want to delete a line, don't write it at all.

    Finally, kill the input file and rename the output file.

    It is all in that previous example, just need to tweak it to your circumstances.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    thanks for everything
    i succeeded but still i can not find the way
    if 2 continues lines are the same do not write them

    thanks

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post your workbook and input file, and highlight which lines should not be copied.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    Hi
    you can see in the input file
    that if there is 2 lines one after anther looking like
    "--------------------------------------------------------------------------------"
    those 2 lines should not be copied.
    but if after 1 line there is some thing else it ok to copy.

    thanks
    sorry i could not highlight those lines.

    Oleg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •