0

I managed to generate a Pivot table using VBA, but now not sure how to sort the "Grand Total" column on the right from Largest to Smallest using VBA that the pivot table generates. A little googling and I found https://docs.microsoft.com/en-us/office/vba/api/excel.pivotfield.autosort but I am not sure how exactly to implement it for the desired result. I have tried moving things around, but seem to be missing some underlying logic (as you will see in this Pastebin link https://pastebin.com/jpjxrTyQ). The VBA code works well up until 'Insert Data field (Count of "group").

I'm definitely not seeing something basic. Any help is appreciated.

Pivot Table 2

Pivot Table

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.