help with refining a recorded macro sort 15 pivot tables

Access Beginner

Active Member
Joined
Nov 8, 2010
Messages
311
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have 15 pivot tables on a sheet called "Zone_PT" and I'd like to sort (Descending) each pivot table by "Sum of % of Variance". Pivot Tables are numbered PivotTable1 to PivotTable15.
I've recorded the below for the 1st four pivot tables.
Can someone please have alook at creating a more efficient code to sort all 15 pivot tables?

Code:
Sub SortZonePts()
'
' SortZonePts Macro
'
'
    Range("E10").Select
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Topic").AutoSort _
        xlDescending, "Sum of % of Variance", ActiveSheet.PivotTables("PivotTable1"). _
        PivotColumnAxis.PivotLines(1), 1
    Range("K10").Select
    ActiveSheet.PivotTables("PivotTable2").PivotFields("Topic").AutoSort _
        xlDescending, "Sum of % of Variance", ActiveSheet.PivotTables("PivotTable2"). _
        PivotColumnAxis.PivotLines(1), 1
    Range("E32").Select
    ActiveSheet.PivotTables("PivotTable3").PivotFields("Topic").AutoSort _
        xlDescending, "Sum of % of Variance", ActiveSheet.PivotTables("PivotTable3"). _
        PivotColumnAxis.PivotLines(1), 1
    Range("K33").Select
    ActiveSheet.PivotTables("PivotTable4").PivotFields("Topic").AutoSort _
        xlDescending, "Sum of % of Variance", ActiveSheet.PivotTables("PivotTable4"). _
        PivotColumnAxis.PivotLines(1), 1
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,213,489
Messages
6,113,952
Members
448,535
Latest member
alrossman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top