Access Beginner
Active Member
- Joined
- Nov 8, 2010
- Messages
- 311
- Office Version
- 2016
- Platform
- 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?
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