title: F# Excel Range.Sort Fails or Rearranges Columns
body: <p>I have two cases. The preliminary code:</p>
  
  <pre><code>open Microsoft.Office.Interop.Excel
  
  let xl = ApplicationClass()
  xl.Workbooks.OpenText(fileName...)
  let wb = xl.Workbooks.Item(1)
  let ws = wb.ActiveSheet :?&gt; Worksheet
  
  let rows = string ws.UsedRange.Rows.Count
  </code></pre>
  
  <p>First, I try the following to sort:</p>
  
  <pre><code>ws.Sort.SortFields.Clear()
  ws.Sort.SortFields.Add(xl.Range("A8:A" + rows), XlSortOn.xlSortOnValues, XlSortOrder.xlAscending, XlSortDataOption.xlSortNormal) |&gt; ignore
  ws.Sort.SortFields.Add(xl.Range("H8:H" + rows), XlSortOn.xlSortOnValues, XlSortOrder.xlAscending, XlSortDataOption.xlSortNormal) |&gt; ignore
  ws.Sort.SetRange(xl.Range("A7:I" + rows))
  ws.Sort.Header &lt;- XlYesNoGuess.xlYes
  ws.Sort.MatchCase &lt;- false
  ws.Sort.Orientation &lt;- XlSortOrientation.xlSortRows
  ws.Sort.SortMethod &lt;- XlSortMethod.xlPinYin
  ws.Sort.Apply()
  </code></pre>
  
  <p>This results in "The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank.".</p>
  
  <p>Then I try the following to sort:</p>
  
  <pre><code>ws.Range("A7:I" + rows).Sort(xl.Range("A8:A" + rows), XlSortOrder.xlAscending,
                               xl.Range("H8:H" + rows), "", XlSortOrder.xlAscending,
                               "", XlSortOrder.xlAscending, XlYesNoGuess.xlYes,
                               XlSortOrientation.xlSortRows) |&gt; ignore
  </code></pre>
  
  <p>This results in my columns being rearranged, though I don't see any logic to the rearrangement. And the rows are not sorted.</p>
  
  <p>Please tell me what I'm doing wrong.</p>