sort pivottable by 2 pivotfields

ebotman

Board Regular
Joined
Jun 24, 2004
Messages
89
Hi I am wondering here if somebody has a smart solution to solve the following issue I am facing.

I would like to write a VBAcode for sorting a pivottable based on both a pivotfielditem ("gcam") and a data sourcefield ("budget").

In the pivottable data I have two sourcefields called "forecast" and "budget". In rows, there are two pivottable fields: "measure" (such as gcam) and "country". Now I would like to have the countries sorted by the budgeted gcam (see numbers appearing in red), and keep the same order for the other item "volumes"

Below I tried to simulate the pivottable I am trying to produce. I know how to use advanced sorting on a single field, for example budget. But then the countries appear in a different order at the pivotitem "volumes" (Bahrain is the first to appear)

---------------------- Data
Measure Country Budget Forecast
Volumes Austria 6 6
Volumes Algeria 5 4
Volumes Bahrain 7 6
Volumes Antigua 4 3
Volumes Croatia 3 2
GCAM Austria 100 80
GCAM Algeria 90 60
GCAM Bahrain 80 70
GCAM Antigua 70 50
GCAM Bulgaria 60 20
GCAM Croatia 50 30
GCAM Bosnia 40 10

As usual, I appreciate very much any help you can give.
Emiel
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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