View Single Post
 
Old 11-21-2013, 04:28 PM
omahadivision omahadivision is offline Windows 7 32bit Office 2007
Novice
 
Join Date: Oct 2012
Posts: 28
omahadivision is on a distinguished road
Default Way to search for a string in text file, pull out everything until another string?

Hi Guys,

I am trying to think of a way to use Excel to pull data out of a text file. I would want all the data after a certain line but before another line. The starting and ending line would always be the same, but the line numbers and amount of data between the two lines would be different. I would want to pull data line by line without using delimiters, as the data I am pulling from uses a space differently than Excel.

Any tips? This is some coding I've come up with so far. It will only tell me the row that the string I am searching for is on:
Code:
Open Fname For Input As #1
  iRow = 1
  Do While Not EOF(1)
     Input #1, A
     If A = "1990" Then
    MsgBox iRow
     End If
     iRow = iRow + 1
  Loop
  Close 1
Reply With Quote