PC Review


Reply
Thread Tools Rate Thread

creating multiple pivots fails

 
 
mark
Guest
Posts: n/a
 
      16th Sep 2008
Hi.

I wrote an add-in that retrieves numerous parameters, extracts data from the
database, and returns a PivotTable, with none of the fields set... just the
outline of it.

This works fine, for creation of a single pivot table. However, I put it in
a loop to retrieve information for numerous projects, and it's failing at
this line:

pvC.CreatePivotTable TableDestination:="", TableName:=pvName,
DefaultVersion:=xlPivotTableVersion10

pvC is my PivotCache, pvName is the name of the pivot table.

The loop creates a new workbook, so each pivot table is in it's own Excel
workbook.

The error that I get is:

Application-defined or object-defined error

but if I hit Debug, and then hit the continue button (without changing
anything), it works. However, on the next run of the loop, I get the same
error, with no chance to Debug/Continue, and it stops.

However, if I put a Breakpoint into the code at this point, and manually
press the continue button for each run through the loop, it doesn't fail.

So, it appears that something is conflicting in the memory. I'd tried
putting in a DoEvents line, but it has no effect.

Can someone suggest something else to try? Thanks.

mark



 
Reply With Quote
 
 
 
 
mark
Guest
Posts: n/a
 
      17th Sep 2008
> The loop creates a new workbook, so each pivot table is in it's own Excel
> workbook.


I put in a line to close the workbook each time in the loop, and now the
program is continuing on with no troubles.

So, it's something about the connection to the previous pivot that's causing
the next one to fail?

 
Reply With Quote
 
mark
Guest
Posts: n/a
 
      18th Sep 2008
> pvC.CreatePivotTable TableDestination:=""

still not sure I know or understand WHY it was failing, but I've found the
solution.

the TableDestination parameter is a variant. If I put in the default "" as
above, the routine fails at the second pivot table.

if I send it an specific range, such as this:

TableDestination:=Range("a1")

Then the program moves merrily along.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Pivots - new pivots based on previous =?Utf-8?B?SG1F?= Microsoft Excel Misc 0 13th Mar 2007 05:23 PM
microsoft multiple pivots =?Utf-8?B?a2F0ZQ==?= Microsoft Excel Misc 2 23rd Jun 2006 12:56 AM
Creating Multiple GIFs from Multiple Range selections -- I need a volunteer to test my code to see why it fails Father Guido Microsoft Excel Programming 0 19th Nov 2005 08:52 AM
I would like to build macro's to do pivots or part of pivots =?Utf-8?B?VG9kZCBGLg==?= Microsoft Excel Programming 2 29th Jul 2005 03:59 PM
Pivots using other pivots and dynamic query problem lc Microsoft Excel Programming 0 7th Nov 2003 03:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:21 AM.