title: VBA sorting Excel rows in ascending order but excluding first row?
body: <p>I was using the below code successfully to, once I populate a worksheet with data, sort the data in ascending order based on the <code>B</code> column, the first row being record headers; <code>B</code> column being the <code>REPTNO</code> column.</p>
  
  <p>For sample data I had B1 containing <code>REPTNO</code> and B2-B17 containing <code>SR0238-SR0253</code>. Everything was good, but then when I cleared out B2-B17 and submitted to user for testing, something strange happened.</p>
  
  <p>My user entered a record into row 2 with the value of <code>JF0007</code> for <code>REPTNO</code>. When my below code processes, my first and second row are flipping (J coming before R), causing my "Header" column to be on the second row instead of remaining on the first.</p>
  
  <p>What do I need to change to sort only the second row onward, excluding the first row? My row 1 needs to remain as row 1 for when I output to a .txt file.</p>
  
  <p>The value of <code>rowCnt</code> in this situation is 2 (The header row + the 1 data row that is entered.</p>
  
  <p><strong>EDIT2:</strong></p>
  
  <pre><code>    ' Sort by REPTNO field
      Dim xlSort As XlSortOrder
      xlSort = xlAscending
  
      If rowCnt &gt; 2 Then
          With Worksheets("Export")
  
              .range("B2:B" &amp; rowCnt).Sort Key1:=.range("B2"), Order1:=xlSort, Header:=xlNo, _
              OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
              DataOption1:=xlSortNormal
          End With
      End If
  </code></pre>
  
  <p>It appears to only be swapping the first row (Header row) when there is 1 record entered (row 2). When I inputted a second data record into row 3 <code>REPTNO = JF0005</code>, the <code>REPTNO</code> value remained as B1. It does however appear this code is not functioning as I thought it was.</p>
  
  <p>I need to sort all the rows (row 2 - however many rows there are) based on their <code>REPTNO</code> value. Sadly, my current code is ONLY ordering the data in the <code>REPTNO</code> column, or <code>B</code>.</p>