ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting Page fields in PivotTable (https://www.excelbanter.com/excel-programming/298358-sorting-page-fields-pivottable.html)

Todd huttenstine

Sorting Page fields in PivotTable
 
The below code is supposed to sort each pivotfield in
pagefield by ascending order. I am getting the
error "Unbale to get the pivotfields property of the
PivotTable class" What is wrong with the code?

Dim PvtTable
Dim CurrentPageField
Set PvtTable = Worksheets("Wkly Renewals").PivotTables
("PivotTable4")
For Each pvtitem In PvtTable.PageFields
CurrentPageField = pvtitem.Name
ActiveSheet.PivotTables("PivotTable4").PivotFields
(pvtitem).AutoSort _
xlAscending, pvtitem
Next

Todd Htutenstine

Sorting Page fields in PivotTable
 
Hey guys

Nevermind this post. I forgot to add .name to pvtitem.

TOdd


-----Original Message-----
The below code is supposed to sort each pivotfield in
pagefield by ascending order. I am getting the
error "Unbale to get the pivotfields property of the
PivotTable class" What is wrong with the code?

Dim PvtTable
Dim CurrentPageField
Set PvtTable = Worksheets("Wkly Renewals").PivotTables
("PivotTable4")
For Each pvtitem In PvtTable.PageFields
CurrentPageField = pvtitem.Name
ActiveSheet.PivotTables("PivotTable4").PivotField s
(pvtitem).AutoSort _
xlAscending, pvtitem
Next
.



All times are GMT +1. The time now is 01:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com