Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Pivot Tables

Hi,

I am using the following code to change the data of a pivot table. I am
wanting all my pivot to use the same data source as "PivotTable1".

Private Sub Worksheet_Activate()
Range("B17").Select
Activesheet.PivotTableWizard SourceType:=xlPivotTable,
SourceData:="PivotTable1"
End Sub

The above code is only referencing PivotTable1 on the same sheet. I need it
to reference PivotTable1 on a different sheet?

The problem is "PivotTable1" is on a different worksheet to all the other
pivots. How do I refereance in code that I want my Pivots in sheet2 to
reference the data source of the pivot in sheet1?

Hope the above makes sense.

Thanks

Paul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Pivot Tables

dim pCache as PivotCache
dim pt1 as PivotTable
set pCache = Worksheets("Sheet1").PivotTables("PivotTable1").Pi votCache
set pt1 = pCache.CreatePivotTable( _
TableDestination:=Worksheets("sheet2").Range("B17" ), _
TableName:="PivotTable1")

I forget which version added the pivottable object with the ability to
create pivottables, but hopefully something like the above will work for you.

--
Regards,
Tom Ogilvy


"Paul Grayson" wrote:

Hi,

I am using the following code to change the data of a pivot table. I am
wanting all my pivot to use the same data source as "PivotTable1".

Private Sub Worksheet_Activate()
Range("B17").Select
Activesheet.PivotTableWizard SourceType:=xlPivotTable,
SourceData:="PivotTable1"
End Sub

The above code is only referencing PivotTable1 on the same sheet. I need it
to reference PivotTable1 on a different sheet?

The problem is "PivotTable1" is on a different worksheet to all the other
pivots. How do I refereance in code that I want my Pivots in sheet2 to
reference the data source of the pivot in sheet1?

Hope the above makes sense.

Thanks

Paul


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Pivot Tables

I have tried this but because I have a pivot table called PivotTable1 on the
sheet I am trying to get the pivots updated I get the following error
message:-

'Run time error 1004'
A pivot table report with that name already exists on the destination sheet?

Any ideas how I can solve this?

Thanks again

Paul


"Tom Ogilvy" wrote:

dim pCache as PivotCache
dim pt1 as PivotTable
set pCache = Worksheets("Sheet1").PivotTables("PivotTable1").Pi votCache
set pt1 = pCache.CreatePivotTable( _
TableDestination:=Worksheets("sheet2").Range("B17" ), _
TableName:="PivotTable1")

I forget which version added the pivottable object with the ability to
create pivottables, but hopefully something like the above will work for you.

--
Regards,
Tom Ogilvy


"Paul Grayson" wrote:

Hi,

I am using the following code to change the data of a pivot table. I am
wanting all my pivot to use the same data source as "PivotTable1".

Private Sub Worksheet_Activate()
Range("B17").Select
Activesheet.PivotTableWizard SourceType:=xlPivotTable,
SourceData:="PivotTable1"
End Sub

The above code is only referencing PivotTable1 on the same sheet. I need it
to reference PivotTable1 on a different sheet?

The problem is "PivotTable1" is on a different worksheet to all the other
pivots. How do I refereance in code that I want my Pivots in sheet2 to
reference the data source of the pivot in sheet1?

Hope the above makes sense.

Thanks

Paul


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Pivot Tables

Sure, give it a different name - one that you are not using.

--
Regards,
Tom Ogilvy


"Paul Grayson" wrote:

I have tried this but because I have a pivot table called PivotTable1 on the
sheet I am trying to get the pivots updated I get the following error
message:-

'Run time error 1004'
A pivot table report with that name already exists on the destination sheet?

Any ideas how I can solve this?

Thanks again

Paul


"Tom Ogilvy" wrote:

dim pCache as PivotCache
dim pt1 as PivotTable
set pCache = Worksheets("Sheet1").PivotTables("PivotTable1").Pi votCache
set pt1 = pCache.CreatePivotTable( _
TableDestination:=Worksheets("sheet2").Range("B17" ), _
TableName:="PivotTable1")

I forget which version added the pivottable object with the ability to
create pivottables, but hopefully something like the above will work for you.

--
Regards,
Tom Ogilvy


"Paul Grayson" wrote:

Hi,

I am using the following code to change the data of a pivot table. I am
wanting all my pivot to use the same data source as "PivotTable1".

Private Sub Worksheet_Activate()
Range("B17").Select
Activesheet.PivotTableWizard SourceType:=xlPivotTable,
SourceData:="PivotTable1"
End Sub

The above code is only referencing PivotTable1 on the same sheet. I need it
to reference PivotTable1 on a different sheet?

The problem is "PivotTable1" is on a different worksheet to all the other
pivots. How do I refereance in code that I want my Pivots in sheet2 to
reference the data source of the pivot in sheet1?

Hope the above makes sense.

Thanks

Paul


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Pivot Tables

Change the new PivotTable name to PivotTable2

dim pCache as PivotCache
dim pt1 as PivotTable
set pCache = Worksheets("Sheet1").PivotTables("PivotTable1").Pi votCache
set pt1 = pCache.CreatePivotTable( _
TableDestination:=Worksheets("sheet2").Range("B17" ), _
TableName:="PivotTable2")

I prefer to use pivot table names as a descriptor of what the pivot table
reports, such as TableName:="ByRegion" or "BySalesman" etc.... allowing
other coders, who might come behind me, to readily pick up on what code I
attached to what pivot table. Also, when loading a new pivot table with
code, since all the other pivot table names have to be considered (can not
match names), it is less likely to match an existing name if it is not in
the PivotTable1, PivotTable2,...etc range of names.

Alan


"The only dumb question is the question left unasked."


"Paul Grayson" wrote in message
...
I have tried this but because I have a pivot table called PivotTable1 on
the
sheet I am trying to get the pivots updated I get the following error
message:-

'Run time error 1004'
A pivot table report with that name already exists on the destination
sheet?

Any ideas how I can solve this?

Thanks again

Paul


"Tom Ogilvy" wrote:

dim pCache as PivotCache
dim pt1 as PivotTable
set pCache = Worksheets("Sheet1").PivotTables("PivotTable1").Pi votCache
set pt1 = pCache.CreatePivotTable( _
TableDestination:=Worksheets("sheet2").Range("B17" ), _
TableName:="PivotTable1")

I forget which version added the pivottable object with the ability to
create pivottables, but hopefully something like the above will work for
you.

--
Regards,
Tom Ogilvy


"Paul Grayson" wrote:

Hi,

I am using the following code to change the data of a pivot table. I
am
wanting all my pivot to use the same data source as "PivotTable1".

Private Sub Worksheet_Activate()
Range("B17").Select
Activesheet.PivotTableWizard SourceType:=xlPivotTable,
SourceData:="PivotTable1"
End Sub

The above code is only referencing PivotTable1 on the same sheet. I
need it
to reference PivotTable1 on a different sheet?

The problem is "PivotTable1" is on a different worksheet to all the
other
pivots. How do I refereance in code that I want my Pivots in sheet2 to
reference the data source of the pivot in sheet1?

Hope the above makes sense.

Thanks

Paul




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
Building pivot tables in Excel 2007 based on existing pivot tables? [email protected] Excel Discussion (Misc queries) 4 December 26th 07 08:05 PM
Pivot Table Data Adding contents of two pivot tables and param que Roundy Excel Discussion (Misc queries) 0 July 2nd 07 10:20 PM
Average Calculations from Pivot Tables - Get Pivot Data? Calc Fiel westy Excel Worksheet Functions 5 March 10th 07 01:31 AM
How does the term 'pivot' apply to Excel's Pivot tables and Pivot. stvermont Excel Discussion (Misc queries) 1 February 17th 05 01:34 AM
Pivot tables-controlling user interaction with pivot tables Sindhura Excel Programming 0 August 27th 03 02:10 PM


All times are GMT +1. The time now is 06:53 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"