Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a PivotTable in a Different Workbook

I have been trying to create the PivotTable in a different
Workbook than the one containing the Macro and the source
data, but I have an error every time.

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= "Database").CreatePivotTable
TableDestination:="[Test.xls]Sheet1!R3C1",
TableName:="PivotTable1"

I would like to have the table in the file Test.xls
Is there a solution?

Thanks for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Creating a PivotTable in a Different Workbook

I looked at VBA's help for tabledestination and found this:

TableDestination Required Variant. The cell in the upper-left corner of the
PivotTable report’s destination range (the range on the worksheet where the
resulting PivotTable report will be placed). The destination range must be on a
worksheet in the workbook that contains the PivotCache object specified by
expression.

=====
But I recorded a macro and the next line in my macro would accept the other
workbook's worksheet range:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"DataBase").CreatePivotTable TableDestination:="", _
TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion10

ActiveSheet.PivotTableWizard _
TableDestination:=Workbooks("test.xls") _
.Worksheets("sheet1").Cells(3, 1)

I used xl2002, so some of the options may not work for you (defaultversion was
added in xl2002, IIRC).

Might be worth a try.

Bernard wrote:

I have been trying to create the PivotTable in a different
Workbook than the one containing the Macro and the source
data, but I have an error every time.

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= "Database").CreatePivotTable
TableDestination:="[Test.xls]Sheet1!R3C1",
TableName:="PivotTable1"

I would like to have the table in the file Test.xls
Is there a solution?

Thanks for your help


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating PivotTable in Excel2007 Kealkil4 Excel Discussion (Misc queries) 0 March 1st 10 12:30 PM
Problem with creating pivottable Ruben Excel Discussion (Misc queries) 0 August 27th 08 11:45 AM
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
Error message when creating PivotTable Alexandre Excel Discussion (Misc queries) 1 November 27th 06 10:06 AM
Creating Multiple Charts from One PivotTable mkehoe Charts and Charting in Excel 0 March 17th 06 11:57 PM


All times are GMT +1. The time now is 11:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"