Thursday, March 8, 2012

how to fetch / copy data from text file to a spreadsheet?

Here I am giving you an idea on how can we fetch or copy the data from a text file to a spreadsheet?


Sub FetchDataFromTextFile()
Dim i As Long
Dim LineText As String
Open "C:\YourPath\YourTextFile.txt" For Input As #24
i = 1
While Not EOF(24)
Line Input #24, LineText
ActiveSheet.Cells(i, 1).Value = LineText
i = i + 1
Wend
Close #24
End Sub


I have not commented on any line expecting you could understand, if not please write a comment or mail me. Thank you.

No comments:

Post a Comment