Andreas Hermle
asked on
Sorting a pivot table on a specific data value field by means of a macro
Dear Experts,
I got a pivot table (MyPivotTable) to which I added a copy of the sales field to the values area of the pivot table to show values as a difference from the previous year.
I named this field 'Dev 20/21'
I now would like to do the sorting ...
... for the 'Dev 20/21' values in descending order for the countries of EACH Sales Area
(Sales Area 01, 02, 03, 04) by means of a macro.
So the macro should do these tasks in one go.for all Sales Areas.
I tried to tweak a macro I recently got from Ejgil from EE for another task but I did not succeed in altering it.
Help is very much appreciated. I have attached a sample file for your convenience.
Regards, Andreas
Sort_Field_Dev_20_21.xlsm
I got a pivot table (MyPivotTable) to which I added a copy of the sales field to the values area of the pivot table to show values as a difference from the previous year.
I named this field 'Dev 20/21'
I now would like to do the sorting ...
... for the 'Dev 20/21' values in descending order for the countries of EACH Sales Area
(Sales Area 01, 02, 03, 04) by means of a macro.
So the macro should do these tasks in one go.for all Sales Areas.
I tried to tweak a macro I recently got from Ejgil from EE for another task but I did not succeed in altering it.
Sub Sort_Dev20_21()
ActiveSheet.PivotTables("PT_Overview").PivotFields("Land").AutoSort xlAscending _
, "Dev 20/21", ActiveSheet.PivotTables("PT_Overview").PivotColumnAxis.PivotLines(1), 1
End Sub
Help is very much appreciated. I have attached a sample file for your convenience.
Regards, Andreas
Sort_Field_Dev_20_21.xlsm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.