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

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,323
Office Version
365, 2019, 2016, 2010
Platform
Windows, 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
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
34,323
Office Version
365, 2019, 2016, 2010
Platform
Windows, 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
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
34,323
Office Version
365, 2019, 2016, 2010
Platform
Windows, 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!
 

Forum statistics

Threads
1,081,728
Messages
5,360,925
Members
400,602
Latest member
newaqua

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top