VBA Macro Pivot - Values differ from Manual creation

mukkak

New Member
Joined
May 28, 2015
Messages
1
Hi All,

i am using below code to create a Pivot table from Macro.
My macro creates around 40-50 pivot tables for several branches.

Using the same data , if I create a pivot table Pivot data field count is 134.
But, if the Pivot is created using macro at run time, value is 72.

I checked if we have duplicate in amounts , but no duplicates found.
I removed few other branches data from my source and ran macro, this time macro created table have the field count as 134.

Below is my sample code :



ActiveSheet.PivotTableWizard SourceType:=xlDatabase, _
SourceData:=DataRange, TableDestination:=Destination, TableName:="Volume"

ActiveSheet.PivotTables("Volume").AddDataField ActiveSheet.PivotTables( _
"Volume").PivotFields("Amount"), "Count of Amount", xlCount


This is a bit surprising for me as count returns invalid data when we have several branches (20-40) data and Pivot works really when Source has 3-4 branches data.

Please assist , if I can change any settings or something to get this fixed.
Thanks very much
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,203,514
Messages
6,055,836
Members
444,828
Latest member
StaffordStag

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