Solved

Excel & VBA to create Pivot Table

Posted on 2011-03-17
4
213 Views
Last Modified: 2012-05-11
I recorded a Macro of me creating a pivot table then attempted to step through the execution (after removing the one I had created) and I get an error on this line;
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "NRDetails[#All]", Version:=xlPivotTableVersion12).CreatePivotTable _
        TableDestination:="Not Ready Summary!R3C1", TableName:="PivotTable1", _
        DefaultVersion:=xlPivotTableVersion12

Open in new window


"NRDetails[#All]" refers to a table on another worksheet.
I've tried changing the name of the worksheet in case there was a remnant in memory of the table name but that didn't change anything.
What am I missing?
0
Comment
Question by:bouscal
  • 2
  • 2
4 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35158391
Is the data sheet active when you run the code?
0
 
LVL 7

Author Comment

by:bouscal
ID: 35158530
Get an 'invalid procedure call' no matter which sheet is active.
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 35158571
Does the Not Ready Summary sheet exist? If so, try changing the destination argument to:
"'Not Ready Summary'!R3C1"
rather than:
"Not Ready Summary!R3C1"

Note the single quotes around the sheet name.
1
 
LVL 7

Author Closing Comment

by:bouscal
ID: 35159074
Thank you, the single quotes made it work!!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now