Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
line input problem-need to return 5 lines after a string is found
I've been tinkering with this for a few hours and can't seem to get it
to work correctly. I'm using line input to go through each line looking for a string. When the string is found, i want to return the line it came from, and the 4 lines below it. Would this be easier with an array? Or do I just have the loop/for sequencing wrong? sub return5lines () dim filename as sstring = "C:\myfile.txt" dim strdata as string dim texttofind as string = "my text" Open filename For Input As #1 Do Until EOF(1) Line Input #1, strdata If InStr(1, strdata, texttofind) Then i = 1 End If For i = 1 To 5 ActiveSheet.Range("a" & i) = strdata i = i + 1 Loop Close #1 end sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem with custom line chart, lines with two axes | Charts and Charting in Excel | |||
URGENT -- search in string for a value in another column, if found, return value from next column | Excel Programming | |||
Marking all lines with same value when a second value is found | Excel Discussion (Misc queries) | |||
Search column - return row found in long text string | Excel Programming | |||
Reads entire *.txt file into string opposed to a desired line by line input. | Excel Programming |