Invalid Procedure Call or Arguement When changing Page item in Pivot table

lala14b

New Member
Joined
Sep 24, 2008
Messages
20
Please help. I have recorded vb that changes a page item in a pivot table when selecting from a combo box - similar to this video.

http://www.datapigtechnologies.com/flashfiles/pivot10.html

The recorded code that vb gives me works only if it's selecting the selection that was chosen when recorded or if it was manually selected right before I choose the drop down item. Otherwise, it gives an invalid procedure call or arguement - runtime error 5.

This occurs in 2007 or compatibility mode. I think this is a new problem since it used to work okay for me.

Does anyone know what's going on??
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
It would help if you showed us some code and an idea of what data is in your fields.
 
Upvote 0
Thanks,

Some of my attempts at code:
Sub SelectPer2()
'
' SelectPer2 Macro
'
'


ActiveSheet.PivotTables("PivotTable6").PivotFields("Period").CurrentPage = Range("Start!d9")

End Sub
Sub Macro10()
'
' Macro10 Macro
'
'Sheets("Rept Sch piv").Select



ActiveSheet.PivotTables("PivotTable6").PivotFields("Period").CurrentPage = Range("Start!d9")
End Sub
Sub Macro11()
'
' Macro11 Macro
'
'
Sheets("Rept Sch piv").Select
ActiveSheet.PivotTables("PivotTable6").PivotFields("Period").CurrentPage = Range("a1")
ActiveSheet.PivotTables("PivotTable9").PivotFields("Quarter").CurrentPage = _
"Q4"
End Sub
 
Upvote 0
1. Is Period a page field?
2. What sort of data is in it?
3. What is in Start!D9?
 
Upvote 0
Yes, period is a page field. It is a selection of 1-12 bases on which month we are reporting. It is a field in the pivot data.

Start d9 is the period #. I also have a names range "period" for this cell If that helps. I've tried this as a dropdown item and as a hard coded #. I was trying to make the pivot dynamic, however would settle on just having it run at all even by having a separate macro for each selection - but this isn't working anymore either. It used to, and it works the first time - which is why I'm so baffled.

Thanks so much for your help!!
 
Upvote 0
Try something like:
Code:
ActiveSheet.PivotTables("PivotTable6").PivotFields("Period").CurrentPage = Cstr(Sheets("Start").Range("D9").Value)
 
Upvote 0
Wow, this seems to be working!! Did the code change in the new version of excel?

Thank you so much!!!
 
Upvote 0
Could you possibly tell me how this would change when using a column and row item? I have other pivots I would like to change as well. I tried changing it to pivotitem, but that didn't work.

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,213,549
Messages
6,114,261
Members
448,558
Latest member
aivin

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