Results 1 to 2 of 2

Text files deleting top 4 rows from multiple files at once

Threaded View

  1. #1
    Registered User
    Join Date
    01-09-2015
    Location
    LONDON
    MS-Off Ver
    2010
    Posts
    23

    Text files deleting top 4 rows from multiple files at once

    I would like an idea how to delete the first four rows/lines/entries of all text files based in a directory. This could be up to 18 files at one time. Typically the header will be
    start/end date , preamble , a source of the file.

    I have experimented with code to do it one at a time but this is not an efficient method.


    Function StripFirstfourLines(strInputFile As String, _
    strOutputFile As String) As Boolean
    On Error GoTo ProcError
    'Dim inzo As String
    'Dim outzo As String
    
    
    
    
    Dim strRecord As String
    
    
    ' Open strInputFile for reading
    Open strInputFile For Input As #1
    'Open inzo For Input As #1
    
    
    ' Create the output filename by opening it.
    Open strOutputFile For Output As #2
    'Open outzo For Input As #2
    
    
    Line Input #1, strRecord
    Line Input #1, strRecord
    Line Input #1, strRecord
    Line Input #1, strRecord
    
    
    Do While (Not EOF(1))
    Line Input #1, strRecord
    Print #2, strRecord
    Loop
    
    
    StripFirstfourLines = True
    
    
    ExitProc:
    On Error Resume Next
    Close 'Close the files
    DoEvents
    Exit Function
    ProcError:
    MsgBox "Error " & Err.Number & ": " & Err.Description, _
    vbCritical, "Error in procedure StripFirstfourLines..."
    StripFirstfourLines = False
    Resume ExitProc
    
    
    End Function
    Last edited by FDibbins; 10-09-2015 at 09:20 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Convert Multiple text files to excel files
    By shanmugapriya.a in forum Excel General
    Replies: 3
    Last Post: 07-07-2015, 10:39 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. [SOLVED] Query multiple text files, one by one to put into rows
    By twofooted in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2014, 06:10 PM
  4. Convert multiple text files to be excel files
    By PStump in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2014, 05:44 PM
  5. 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
  6. split text files stored in some location to multiple files based on a condition
    By GIRISH_KH in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2013, 11:32 AM
  7. Replies: 0
    Last Post: 03-29-2011, 03:10 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