Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding lines between headers text file (VBA/Excel 2000)

    I importing a text file into excel. I need 30 rows between the header keywords(1JDC023R1). I want to count the number of lines between each header keyword and subtract it from 30 then insert the difference with blank lines before the next header. Thanks for any help.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding lines between headers text file (VBA/Excel 2000)

    How are you going to use this in Excel? It doesn't seem an easy job to get this into some kind of usable format.

  3. #3
    New Lounger
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding lines between headers text file (VBA/Excel 2000)

    A third party wrote a program in VBA using excel to read in a text document with fixed number of repeating rows and then pass it to SQL Server. Unfortunately, I can't get the source that builds this file to create a file with a fixed number of rows. So, I am trying to alter the VBA to do this in the program.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding lines between headers text file (VBA/Excel 2000)

    Just to make sure: do you want to insert lines in the original text file? Or do you want to insert rows in the Excel spreadsheet that results from importing the text file?

  5. #5
    New Lounger
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding lines between headers text file (VBA/Excel 2000)

    I would like to insert the lines into the original file, but at this point I will do whatever is easiest.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding lines between headers text file (VBA/Excel 2000)

    The attached VBA procedure will add lines in the text file. Call it like this:

    FillTo30 "testPackSlip.txt"

    if the text file is in the current folder, or

    FillTo30 "testPackSlip.txt", "C:Test"

    if the text file is in a folder C:Test. The second argument must contain a trailing backslash.

    Notes:
    - For testing purposes, the procedure will create a new file at the moment; uncomment two lines near the end (indicated in the code) to make it overwrite the original.
    - The code is generic VBA, it can be run from any application with VBA (Word, Excel, Access, VB6)

  7. #7
    New Lounger
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding lines between headers text file (VBA/Excel 2000)

    It worked perfectly - Thanks so much!

Posting Permissions

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