Pivot value field type VBA

Broken notes

New Member
Joined
Dec 21, 2016
Messages
3
Hello all,

I am trying to add value fields to a pivot table via a macro run from a user form (just named ranges on a worksheet), and I am having trouble finding a way to select what value field type is required ie sum, count etc.

The line specifies the sheet containing the pivot and the pivot name (both referencing named ranges where the user inputs this information), adds the field and the final term (currently xlSum) specifies the value field type. I want this final term to come from a referenced named range also ( for example Range("value_field_type).Value). however no matter what I try I can't get this to work (the fields do not populate). If the term is left as xlSum it works just fine.
Any ideas?

Any help would be much appreciated.

Cheers!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,854
Messages
6,127,339
Members
449,377
Latest member
CastorPollux

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