title: VBA error Method 'Add' of object 'SortFields' failed
body: <p>I am trying to sort a list from column A of excel sheet. I recorded the macro and wrote the subroutine by replacing the activeworksheet by my sheet object. Still I got following error even though the code till this line works fine and to my knowledge there is no problem with the declaration.
  Error: Run-time-error '-2147417851(80010105)
  'Method 'Add' of object 'SortFields' failed.!</p>
  
  <pre><code>Dim ExlWB As Excel.Workbook
  Dim ExlWS As Excel.Worksheet
  
  Set ExlWB = ExlApp.Workbooks.Open(ThisWorkbook.Path &amp; "\Sample.xlsx")
  Set ExlWS = ExlWB.Sheets(1)
  
  ExlWS.Range("$A$2:$B$" &amp; Rows + 1).RemoveDuplicates Columns:=1, Header:=xlNo
  ExlWS.Sort.SortFields.Clear
  ExlWS.Sort.SortFields.Add Key:=Range("A2"), _
      SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  With ExlWS.Sort
      .SetRange Range("A2:B" &amp; ExlWS.Range("A1").End(xlDown).Row)
      .Header = xlNo
      .MatchCase = False
      .Orientation = xlTopToBottom
      .SortMethod = xlPinYin
      .Apply
  End With
  </code></pre>
  
  <p>Can anyone tell what might be the error.
  Thank you in advance.</p>