+ Reply to Thread
Results 1 to 2 of 2

Using Macro recorder with Pivot Tables

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    11

    Using Macro recorder with Pivot Tables

    Hi guys,

    I am trying to build a macro for the creation of pivot tables. Since I am very new to excel, i cannot code this myself and have resorted to using the macro recorder.

    However, after i have recorded my macro and i try to run it i get the following error:

    Run-time error '5'

    Invalid procedure call or argument


    In the debugger, this portion of the code is highlighted(it is right at the top):

    Please Login or Register  to view this content.


    Would anyone please be able to explain how I should go about fixing this?

    What I am doing doesnt even seem to complex. I simply start the recorder, hit insert pivot chart, set up the correct fields in the pivot table, fix up the pivot chart type and then I stop recording.


    Any help, tips or pointers would be greatly appreciated!


    Cheers,
    Nima
    Last edited by arlu1201; 09-05-2012 at 04:06 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Using Macro recorder with Pivot Tables

    Hi, Nima,

    if you recorded the macro and run it without deleting the Pivot Table that has been used for recording the macro will try to build a new PT under the very same name:

    Please Login or Register  to view this content.
    As the range fopr the data may differ please try this piece of code instead where both Sheetname as well as Name of PT are passed to the code:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    There must be a Sheet4 in your workbook and no PT called PT_Nima_4. If you want to run the code again, either delete the PT or pass a new name for it.

    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1