Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading files

Status
Not open for further replies.

Newbie311

Programmer
Oct 6, 2003
30
GB
Hi im using the below code to read in textfiles and then displaying various results from the files on an excel spreadsheet.Ive managed to get it reading in files and displaying data however it browses the folder and only displays the data from the last file what am i doing wrong?
Cheers

Public Sub readDataFromFile()

Dim myFile As String
Dim FF As Integer
Dim temp As String
Dim r As Integer
Dim fso As Object
Dim fld As Object
Dim fileN As Object
Dim foldername As String
Dim x As Integer
Dim y As Integer
Dim GetLine As String


Set myBook = ActiveWorkbook
Set mysheet = myBook.Sheets(1)

x = 0


Set fso = CreateObject("scripting.FileSystemobject")

myFile = "DIRECTORY"

Set fld = fso.GetFolder(myFile)

For Each fileN In fld.Files

i = FreeFile
Open fileN For Input As #i
Do While Not EOF(i)
Line Input #i, GetLine

' Code to extract data goes here

Loop

Close #i

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top