2

I'm using Excel 2010 and currently writing some VBA code to control my pivot-table.

My issue is that I'm using Shapes to access a vba macro responsible to sort my table and it only works when I sort the first column of my pivot table.

Here's the code I'm using :

Worksheets("Sheet1").PivotTables("Pivot table 1") _ 
.PivotFields("Data").AutoSort xlAscending, "Data"

But it only works if "Data" is the name of my first column. If I try to sort my table using my second of third column, nothing happens.

I though that maybe I have to remove the sorting from other columns before trying to sort my table but I haven't managed to make that option work and I'm running out of ideas.

Thank you

ElCapitaine
  • 830
  • 1
  • 11
  • 24
  • I think you'll find that the data in the 2nd and 3rd columns, i.e., the 2nd and 3rd row fields, is sorted. It's just sorted within the 1st and 2nd columns. If you want to sort the entire 2nd column, you could move it to the first position. – Doug Glancy Sep 17 '13 at 17:30
  • I'm trying to avoid moving the columns, since it is destined to users who have to access this data all the time, moving columns each time I want to sort data will get them confused quickly. – ElCapitaine Sep 18 '13 at 12:27

0 Answers0