How to sort a pivot table with VBA?

vanclute

Board Regular
Joined
Oct 23, 2002
Messages
218
I'm using Mac Excel 2011, trying to sort a pivot table but it's not behaving.

I found this thread:

[SOLVED] Excel 2011 - Trying to Sort Pivot Table

and tweaked the code to suit my names of things:

Worksheets("performance").PivotTables(1).PivotFields("date").AutoSort xlDescending, "Row Labels"

but it doesn't do a thing. No errors either... not sure what the trouble might be. Anyone have any suggestions?

My field name is "date" and the caption on the pivot table itself is "Row Labels".
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Furthermore, when I sort by recording a macro, I end up with:

ExecuteExcel4Macro "(1,,2,2,1)"

However trying to play it back, results in an error 1004. Why would the macro recorder produce code that it can't play back itself?
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,790
Members
449,468
Latest member
AGreen17

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