Solved

Excel & VBA to create Pivot Table

Posted on 2011-03-17
4
215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

919 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

17 Experts available now in Live!

Get 1:1 Help Now