Use a Do...While loop to keep reading records until you've reached the end of the file: : Text File « File Path « VBA / Excel / Access / Word






Use a Do...While loop to keep reading records until you've reached the end of the file:

 
Sub ImportAll()
    ThisFile = "C:\sales.txt"
    Open ThisFile For Input As #1
    Ctr = 0
    Do
        Line Input #1, Data
        Ctr = Ctr + 1
        Cells(Ctr, 1).Value = Data
    Loop While EOF(1) = False
    Close #1
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.Filtering a text file
4.Read a text file, skipping the Total lines
5.Read a text file, adding the amounts
6.Reading Text Files One Row at a Time
7.Writing Text Files