title: Excel SortFields add then sort
body: <p>Would you help me understand this snippset: </p>
  
  <p>First, it seems that a sorting rule is added with </p>
  
  <pre><code>MainSheet.Sort.SortFields.Clear
  For lI = 1 To vSortKeys(0, 1)   
      MainSheet.Sort.SortFields.Add Key:=Range(vSortKeys(lI, 1) &amp; 2), 
         SortOn:=xlSortOnValues, Order:=vSortKeys(lI, 2), DataOption:=xlSortNormal
  Next
  </code></pre>
  
  <p>Then, I understand that the following code is effectively running the sort</p>
  
  <pre><code>With MainSheet.Sort
      .SetRange Range("A" &amp; lFrom &amp; ":" &amp; GEN_REV_END &amp; lTo)
      .Header = xlNo
      .MatchCase = False
      .Orientation = xlTopToBottom
      .SortMethod = xlPinYin
      .Apply
  End With
  </code></pre>
  
  <p>Is this interpretation correct - need to add a sorting rule first, then apply it with the second part ?</p>
  
  <p>Then, why are we defining a range for sort in the second part, in</p>
  
  <pre><code>With MainSheet.Sort
      .SetRange Range("A" &amp; lFrom &amp; ":" &amp; GEN_REV_END &amp; lTo)
  
  End With
  </code></pre>
  
  <p>Is it not already in the rule that we sort for <code>Key:=Range(vSortKeys(lI, 1) &amp; 2)</code> ? On which range of cells is the sort effectively run ?</p>