title: Excel VBA - Clarification
body: <p>I was just wondering if anybody had any advice on what this piece of VBA code is doing. A colleague of mine left recently and hadn't commented any of their work so I am a bit confused.</p>
  
  <p>There is some code to sort some cells but I'm not sure how it knows what to sort, as a range is specified which isn't the data I want sorting. I think I am missing something but nothing online seems to explain Excel VBA in a very good manner.</p>
  
  <p>The code looks like this:</p>
  
  <pre><code>    Range(Selection, Selection.End(xlDown)).Select
      ActiveWorkbook.ActiveSheet.SORT.SortFields.Clear
      ActiveWorkbook.ActiveSheet.SORT.SortFields.Add Key:=ActiveCell, _
          SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
          xlSortTextAsNumbers
      With ActiveWorkbook.ActiveSheet.SORT
          .SetRange ActiveCell.Range("A1:A550")
          .Header = xlNo
          .MatchCase = False
          .Orientation = xlTopToBottom
          .SortMethod = xlPinYin
          .Apply
      End With
      ActiveCell.Offset(0, 1).Range("A1").Select
  </code></pre>
  
  <p>I know that the top stuff sets the criteria to be used to sort the data, but I am unsure why range("A1:A550") is there, as the data to be sorted usually begins somewhere around cell C15. Is the code just saying "Use the current cell as A1, select the next 550 rows down from this and sort the data accordingly"?</p>
  
  <p>Thank you all in advance.</p>