title: How can I only sort thru the rows with data?
body: <p>I have a macro that sorts the rows by a specific column, the problem is I'm manually setting the range for the number of rows to sort (i.e. A2:A174) every time I add a new row.  How can I change my code so that it sorts all the rows with data only so I don't have to go into the code and change the range every time I add a new row.</p>
  
  <pre><code>Sub SortByName()
  
    SortByName Macro
  
      ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
      ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A2:A174") _
          , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
      With ActiveWorkbook.Worksheets("Sheet1").Sort
          .SetRange Range("A1:H174")
          .Header = xlYes
          .MatchCase = False
          .Orientation = xlTopToBottom
          .SortMethod = xlPinYin
          .Apply
      End With
      Range("A1").Select
  End Sub
  Sub SortByDate()
  </code></pre>
  
  <p>Thanks so much in advance for your wisdom!</p>