title: Select a range of cells between rows with designated values
body: <p>I am trying to format a large text file in Excel. It looks similar to this to begin with:  </p>
  
  <pre><code>Headings  
  ----------  
  Data   
  Data 
  Data  
  ENDROW  
  Other Information  
  </code></pre>
  
  <p>I want to select the cells between ---------- and ENDROW and then use the text to columns function on the selected cells. I recorded a macro for the text to columns bit and eventually I want to use this to loop throughout the entire document.  </p>
  
  <pre><code> Sub findRange()
   Dim nRow As Long
   Dim nStart As Long, nEnd As Long
  
  ' Figure out where the range should start.
  For nRow = 1 To 65536
  If Range("A" &amp; nRow).Value = "----------" Then
  nStart = nRow
  Exit For
  End If
  Next nRow
  
  ' Figure out where the range should end.
  For nRow = nStart To 65536
  If Range("A" &amp; nRow).Value = "ENDROW" Then
  nEnd = nRow
  Exit For
  End If
  Next nRow
  nEnd = nEnd - 1
  
  Range("A" &amp; nStart &amp; ":D" &amp; nEnd).Select
     Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
         FieldInfo:=Array(Array(0, 1), Array(16, 1), Array(21, 1), Array(27, 1), Array(56, 1), _
         Array(59, 1), Array(60, 1), Array(73, 1)), TrailingMinusNumbers:=True
     Selection.ColumnWidth = 16.33
     Range("B:B,F:F,D:D,H:H").Select
     Range("H1").Activate
     Selection.Delete Shift:=xlToLeft
  
  End Sub
  </code></pre>
  
  <p>It's erroring out and any input is appreciated. I am a novice trying to learn my way into this.</p>