Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do you skip lines when reading a text file

Open Strfilename For Input As #iFile
i = 1
Do While Not EOF(iFile)
e = Input(1, #iFile)
z = ""
Do While Not (e = Chr(13) or e = Chr(13)+Chr(10))
z = z & e
e = Input(1, #iFile)
Loop
'Input #iFile, z 'original code begins on this
line
Range("Sheet1!a" & i).Value = z
*** Go to the next line in input...(how do I code that?)
'Input #iFile, z
'Range("Sheet1!b" & i).Value = z
'i = i + 1 'original code ends on this line
Loop
Close #iFile
Exit Sub

Using the code above, I'm trying to skip to the next line in the input
file, the code abov runs a never-ending loop and reads the same line
over and over again. Please help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how do you skip lines when reading a text file

Sub ReadFile()
Dim strFileName As String
Dim i As Long
Dim sLine As String
Dim ifile As Long
strFileName = "C:\data\eclipse.txt"
ifile = FreeFile()
Open strFileName For Input As #ifile
i = 1
Do While Not EOF(ifile)
Line Input #ifile, sLine
Debug.Print i, sLine
i = i + 1
Loop
Close (ifile)
End Sub


--
Regards,
Tom Ogilvy

"Yaw Bonsu" wrote in message
om...
Open Strfilename For Input As #iFile
i = 1
Do While Not EOF(iFile)
e = Input(1, #iFile)
z = ""
Do While Not (e = Chr(13) or e = Chr(13)+Chr(10))
z = z & e
e = Input(1, #iFile)
Loop
'Input #iFile, z 'original code begins on this
line
Range("Sheet1!a" & i).Value = z
*** Go to the next line in input...(how do I code that?)
'Input #iFile, z
'Range("Sheet1!b" & i).Value = z
'i = i + 1 'original code ends on this line
Loop
Close #iFile
Exit Sub

Using the code above, I'm trying to skip to the next line in the input
file, the code abov runs a never-ending loop and reads the same line
over and over again. Please help.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA macro for reading text file into Excel Javed Khan Excel Discussion (Misc queries) 0 October 14th 09 06:29 PM
Reading in poorly formatted text file Some Dude Excel Discussion (Misc queries) 1 February 11th 07 10:24 PM
Reading from a text file Jeff Excel Discussion (Misc queries) 1 November 8th 06 08:47 PM
Reading a text file ? WTG Excel Worksheet Functions 2 February 22nd 05 01:29 AM
Reading a text file WTG Excel Discussion (Misc queries) 2 February 22nd 05 01:27 AM


All times are GMT +1. The time now is 10:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"