Filtering a text file : Text File « File Path « VBA / Excel / Access / Word






Filtering a text file

 
Sub FilterFile()
    Open "infile.txt" For Input As #1
    Open "output.txt" For Output As #2
    TextToFind = "yourText"
    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 and Save Text file
2.Save Date and Time information to a text file
3.Read a text file, skipping the Total lines
4.Read a text file, adding the amounts
5.Reading Text Files One Row at a Time
6.Use a Do...While loop to keep reading records until you've reached the end of the file:
7.Writing Text Files