Avatar of Andreas Hermle
Andreas Hermle
Flag for Germany asked on

Custom sort a pivot table based on the specific sorting of another pivot table

Dear Experts: I placed two pivot table reports one next to the other on a worksheet. Both share the same datasource.

The left pivot table (MyPT-01) has been sorted by Sales 2021 descending. The corresponding countries are now in some specific order.

I would like to sort the countries of the other pivot table (MyPT-02) to match the sorting of the countries of the left Pivot Table (MyPT-01)

I am pretty sure this can only be achieved by means of a macro.

Help is much appreciated, Thank you very much in advance.

I have attached the pivot table file for your convenience.

VBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Ejgil Hedegaard

8/22/2022 - Mon
Rob Henson

I would have thought that you could include Grand Total in your second pivot and sort on that column but that doesn't work in all cases.

Alternatively, how about using a table of SUMIFS formulas alongside the first pivot to get the breakdown data that shows in the second pivot, using the country column from first pivot as one of the criteria.
Andreas Hermle

Hi Rob,

thank you very, very much for your swift answer and the suggested approaches.

As a matter of fact I am looking for a VBA solution. 
Ejgil Hedegaard

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes