Hi all,
I have several pivot table templates built, and had to add in additional items to the page field. They are now out of order (they need to be alphabetical). If I was starting from scratch, I would just pull the pagefield down, sort it, and add it back to the top. However, since the entire page is built with formulas and formatting and such, I need to use code.
SO! Here's what I have so far:
Sub SortAllFields()
On Error Resume Next
Application.ScreenUpdating = False
Dim pt As PivotTable
Dim ws As Worksheet
Dim pf As PivotField
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.ManualUpdate = True
For Each pf In pt.PivotFields
pf.AutoSort xlAscending, pf.Name
Next pf
pt.ManualUpdate = False
Next pt
Next ws
Application.ScreenUpdating = True
End Sub
The problem with this code is that is sorts all pivot fields, and I need it to just sort "Geographies." There is 1 "Geographies" pf per sheet and there are number of sheets in the workbook. I can't figured out how to make the pf specific to "Geographies." Hopefully this makes sense - any help would be appreciated!!
Thanks,
Jill
Bookmarks