+ Reply to Thread
Results 1 to 3 of 3

Running Macro always has error at pivot table creation

  1. #1
    Registered User
    Join Date
    09-13-2011
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    20

    Running Macro always has error at pivot table creation

    Good afternoon to all the smart excel people out there. I need some help. I created a macro which creates a couple of pivot tables and then moves the data which feeds into an "overview" worksheet. However, everytime I run it I get an error at one of the pivot tables. The error is as follows:

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "nov28!R1C1:R65536C25", Version:=xlPivotTableVersion10).CreatePivotTable _
    TableDestination:="Sheet6!R3C1", TableName:="PivotTable1", DefaultVersion _
    :=xlPivotTableVersion10


    Any help on how to solve this? I don't have a clue.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    What's the error message?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Running Macro always has error at pivot table creation

    You might want to try this approach instead. Just create the pivot tables as part of the template and assign them dynamic-named range. The dynamic-named-range will expand/contract to reflect the data in the overview worksheet.

    Then, when the macro runs you can just ask the pivot tables to update. Actually, if the pivot tables are in a separate worksheet (which is usually a good idea also) you can handle the pivot table refreshing with an event macro. Whenever the worksheet with the pivot table is selected, all tables on the sheet can be asked to refresh themselves.

    Can you post an example?
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

+ 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