title: Text File Column Data Extraction with Excel VBA
body: <p>I have code below that extracts data from a text file and sends to a worksheet. Data sends to the worksheet but its a mess. I aim to extract certain columns of data in the text file. Data columns are space delimited and spacing differs between column but ea column has a heading. How can I complete my code to search text file by column header name and send data under that header to the worksheet? A typical header and columns of data underneath is shown below the code. Header blocks and associated data are repeated throughout the text file but are space delimited by rows. Above ea header band is an identifier for that block.</p>
  
  <pre><code>Sub test()
  Dim Path As String
  Dim textline As String
  Dim arr() As String
  Dim i As Long, j As Long
  Path = whatever...
  Open Path For Input As #1
  i = 1
  While EOF(1) = False
  Line Input #1, textline
     arr = Split(CStr(textline), " ")
     For j = 1 To UBound(arr)
     ActiveSheet.Cells(i, j).Value = arr(j - 1)
     Next j
     i = i + 1
  Wend
  Close #1
  End Sub
  </code></pre>
  
  <p>Identifier 1.1</p>
  
  <p>Heave  /</p>
  
  <p>Wave Ampl.</p>
  
  <p>/--------------/</p>
  
  <p>Ampl. Phase</p>
  
  <p>0.123 42</p>
  
  <p>0.131 72</p>
  
  <p>0.433 55</p>