VBA (or other method) for moving field in and out of values area

Bacon117

New Member
Joined
Jul 2, 2010
Messages
11
I need to quickly change which field is listed in the Values area of a pivot table. My current method is to drag the field out of the values area, drag the new field into the values area, right click it, and select average.

I would really like to write a VBA script to handle this for me based on a value in a cell (that has a drop down list populated from the header of my data). BUT, I cannot seem to find a way to determine WHICH field is currently in the values area before deleting it from the pivot table. All of the tutorials (and microsoft reference) show how to remove a field from a pivot chart, but only if you know which field is already there. I suppose I could remove everything, then add it all back, but I think that's a rabbit hold I'm not prepared for.

Any suggestions?

Thanks.
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Maybe an easier question: When I add a field into a pivot table with VBA, how do I specify which area that field should go to?
 
Upvote 0

Forum statistics

Threads
1,216,112
Messages
6,128,901
Members
449,477
Latest member
panjongshing

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