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??
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,811
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
It would help if you showed us some code and an idea of what data is in your fields.
 

lala14b

New Member
Joined
Sep 24, 2008
Messages
20

ADVERTISEMENT

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
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,811
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
1. Is Period a page field?
2. What sort of data is in it?
3. What is in Start!D9?
 

lala14b

New Member
Joined
Sep 24, 2008
Messages
20

ADVERTISEMENT

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!!
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,811
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Try something like:
Code:
ActiveSheet.PivotTables("PivotTable6").PivotFields("Period").CurrentPage = Cstr(Sheets("Start").Range("D9").Value)
 

lala14b

New Member
Joined
Sep 24, 2008
Messages
20
Wow, this seems to be working!! Did the code change in the new version of excel?

Thank you so much!!!
 

lala14b

New Member
Joined
Sep 24, 2008
Messages
20
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,118,404
Messages
5,571,915
Members
412,426
Latest member
DeficientOptimism
Top