title: With VBA, get pivot table values in sorted order
body: <p>In Excel VBA, I followed these steps:</p>
  
  <pre><code>Created a pivot table off another sheet as datasource
  AutoSort the first pivot field based on the first data field
  </code></pre>
  
  <p>The pivot table is displaying everything correctly. Now I'm trying to programmatically access the rows under the first pivot field, and get them in the sort order. But the PivotTable.RowFields collection is returning rows in the original order before sorting. How can I programmatically get rows in the new, sorted order, without writing code to sort the data?</p>
  
  <p>Abstract code snippet</p>
  
  <pre><code>Dim pt As PivotTable
  Dim pf As PivotField
  Dim strval As String
  .
  .
  .
  Set pf = pt.PivotFields("first")
  pf.AutoSort xlDescending, "firstdata", pt.PivotColumnAxis.PivotLines(1), 1
  strval = ptExtract.RowFields(1).PivotItems(1)
  </code></pre>
  
  <p>After these statements, the pivot table does display all values in descending orders. But strval gets the value from the first row before sorting. The order of pivot items in PivotItems does not seem to change after AutoSort. So how do I get these values in the newly sorted order?</p>
  
  <p>Any help would be appreciated. Thanks!</p>