Reputation: 126
I would like to swap the positions of pivot table column headers
Based on the screenshot:
The column headers belong to the "Quote Type" column.
I would like column header TYPE 1 to be on the left of column header TYPE 2, which in turn will be on the left of column header TYPE 3.
Ignore the blanks.
Many thanks!
Upvotes: 0
Views: 250
Reputation: 522
If you just want to do this once you can just drag the headers manually but with VBA you can do something like the below:
With Sheets("YourSheet").PivotTables("YourPivotTable").PivotFields("Quote Type")
.PivotItems("TYPE 1").Position = 1
.PivotItems("TYPE 2").Position = 2
.PivotItems("TYPE 3").Position = 3
End With
Don't forget to replace YourSheet with the name of the worksheet with your pivot table and YourPivotTable with the name of your pivot table!
Note: This will give an error if one of these types isn't in the pivot table. You can add On Error Resume Next before it if you would like or make a custom error handler for it. Please let me know if this is something you need.
Upvotes: 2