Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA macro for reading text file into Excel | Excel Discussion (Misc queries) | |||
Reading in poorly formatted text file | Excel Discussion (Misc queries) | |||
Reading from a text file | Excel Discussion (Misc queries) | |||
Reading a text file ? | Excel Worksheet Functions | |||
Reading a text file | Excel Discussion (Misc queries) |