Pivot Table macros are not working in powerpivot

nataly

New Member
Joined
Jul 20, 2013
Messages
4
Hello,
I have a few macros that work well in pivot tables in Excel 2013. For instance they adjust all titles in the pivot table, or set all value items to sum - simple but helpful macros like that. Macros are found on internet or books and adjusted to make them work for my situation.
Using pivot table macros "as is" in powerpivot gives an error message, produces unwanted results, or crashes excel.
Is there an easy fix to make pivot table macros work for powerpivot as well?
Thanks,
Nataly
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi nataly,
The object model for powerpivot pivots is different than the regular pivot model. These macros will likely need to be updated for the PowerPivot 2013 object model. Putting this in the VBA Forum (Excel Questions) may get you a reply from someone who wants to take a crack at playing with the Powerpivot objects. If you don't get a response, post a workbook with the macros here and I'll take a look.
 
Upvote 0
Hi tjdurkin,
Thanks for the reply! How do I attach a workbook to my post?
Here are a few of my favorite pivot table macros that I would like to work for powerpivot.
+++++++
Sub AdjustAllPivotDataFeildTitles()
Dim pt As PivotTable
Dim pf As PivotField
On Error Resume Next
Set pt = ActiveSheet.PivotTables(ActiveCell.PivotTable.Name)
If pt Is Nothing Then
MsgBox "Cursor is not in PT"
Exit Sub
End If
For Each pf In pt.DataFields
pf.Caption = pf.SourceName & chr(160)
Next pf
End Sub
+++++++++

Sub SetAllDataItemstoSum()
Dim pt As PivotTable
Dim pf As PivotField
On Error Resume Next
Set pt = ActiveSheet.PivotTables(ActiveCell.PivotTable.Name)
If pt Is Nothing Then
MsgBox "Cursor is not in PT"
Exit Sub
End If
For Each pf In pt.DataFields
pf.Function = xlSum
Next pf
End Sub
++++++++

Thank you,
I will post in the VBA forum as well.
Nataly
 
Upvote 0

Forum statistics

Threads
1,215,456
Messages
6,124,939
Members
449,197
Latest member
k_bs

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