Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Error when selecting page itme from pivot table - Runtime error 5 - Invalid Procedure Call or Argument

Latest post Mon, Feb 14 2011 3:23 PM by Uli. 5 replies.
  • Thu, Oct 14 2010 4:00 PM

    • lala14b
    • Not Ranked
    • Joined on Thu, Oct 14 2010
    • Posts 2
    • Points 58

    Error when selecting page itme from pivot table - Runtime error 5 - Invalid Procedure Call or Argument

    Please help!  I have spent way too much time trying to figure this out, so I'm really hoping someone can 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/f...s/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. I don't understand b/c this is what was recorded, and also is the same as in this video.  Does anyone know what's going on??

    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

    • Post Points: 37
  • Tue, Oct 19 2010 9:10 AM In reply to

    • lala14b
    • Not Ranked
    • Joined on Thu, Oct 14 2010
    • Posts 2
    • Points 58

    Re: Error when selecting page itme from pivot table - Runtime error 5 - Invalid Procedure Call or Argument

    anyone have any idea on this?  I am really stuck.

    • Post Points: 21
  • Tue, Oct 19 2010 8:33 PM In reply to

    • Jim Cone
    • Top 10 Contributor
    • Joined on Tue, Jan 15 2008
    • Portland, Oregon - USA
    • Posts 243
    • Points 3,503

    Re: Error when selecting page itme from pivot table - Runtime error 5 - Invalid Procedure Call or Argument

    I am too, however the excel help file for "currentpage" says it is set to the name of the page you want, or it can be set to "All".

    So that could translate to something like...
    ActiveSheet.PivotTables("PivotTable6").PivotFields("Period").CurrentPage ="Sludge"
    or
    ActiveSheet.PivotTables("PivotTable6").PivotFields("Period").CurrentPage = "All"

    Also, the link you provided is broken.
    '---
    Jim Cone
    Portland, Oregon USA
    http://www.mediafire.com/PrimitiveSoftware
    (free and commercial excel programs)

    • Post Points: 21
  • Tue, Oct 19 2010 11:10 PM In reply to

    • Omar
    • Top 10 Contributor
    • Joined on Sat, Jan 12 2008
    • Kitchener, ON
    • Posts 128
    • Points 1,823

    Re: Error when selecting page itme from pivot table - Runtime error 5 - Invalid Procedure Call or Argument

    Omar Freeman Kitchener, ON

    • Post Points: 5
  • Tue, Oct 19 2010 11:19 PM In reply to

    • Omar
    • Top 10 Contributor
    • Joined on Sat, Jan 12 2008
    • Kitchener, ON
    • Posts 128
    • Points 1,823

    Re: Error when selecting page itme from pivot table - Runtime error 5 - Invalid Procedure Call or Argument

    I watched the video. He had a slight difference from your code.

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

    Notice that you didn't include that last .text in your code.

    Omar Freeman Kitchener, ON

    • Post Points: 5
  • Mon, Feb 14 2011 3:23 PM In reply to

    • Uli
    • Not Ranked
    • Joined on Mon, Feb 14 2011
    • Posts 1
    • Points 5

    Re: Error when selecting page itme from pivot table - Runtime error 5 - Invalid Procedure Call or Argument

    I know the answer is late and I don't know whether the issue is already fixed but:

    To me it appears like a MS programming error. I have that problem in a loop that runs from 1 to 8 each time changing the .CurrentPage accordingly. 1 and 3 to 8 work fine, two causes the above mentioned error! Changing the value to 2 manually of course works fine. It just doesn't work from within the VBA code...

     

    BR

    Uli

    • Post Points: 5
Page 1 of 1 (6 items) | RSS
Copyright Excel User Group and the relevant contributors, 2010. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.