Filter File : File Read Write « File Path « VBA / Excel / Access / Word






Filter File

 

Sub FilterFile()
    On Error Resume Next
    Open "c:\infile.txt" For Input As #1
    Open "c:\output.txt" For Output As #2
    If Err <> 0 Then
        MsgBox "Error reading or writing a file."
        Exit Sub
    End If
    TextToFind = "January"
    Do While Not EOF(1)
        Line Input #1, data
        If InStr(1, data, TextToFind) Then
            Print #2, data
        End If
    Loop
    Close

End Sub

 








Related examples in the same category

1.Create a new file