Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Don S
 
Posts: n/a
Default Pivot tables share source data "after the fact"

When you build pivot tables, you are given the option to share source
data with an existingr pivot table (when applicable).

If this option was not selected when the workbook was developed, is
there a way to get pivot tables using the same data table to share the
cache - short of recreating them?

Thanks!
Don S
  #2   Report Post  
Gary Brown
 
Posts: n/a
Default

Great Question!!!
The only way I can think to do this is to know what 'Cache Index' each pivot
table has. The CacheIndex is an identifier of the range of data used for
that pivot table.

To find out what cacheindex each of your pivot tables has, run the macro
below called "Pivot_Table_Information".

Once you've identified which pivot table has which Cache Index, run the
macro below called "Change_My_CacheIndex".
REMEMBER TO CHANGE THE EXAMPLE FOR THE ACTUAL WORKSHEET NAME AND PIVOT TABLE
NAME!!!

HTH,
Gary Brown

'/=====================================/
Sub Pivot_Table_Information()
Dim iRow As Long
Dim PivTbl As PivotTable
Dim wksht As Worksheet
On Error Resume Next

Worksheets.Add.Move _
After:=Worksheets(Worksheets.Count)

ActiveSheet.Range("A1").Value = "Worksheet"
ActiveSheet.Range("B1").Value = _
"Pivot Table Name"
ActiveSheet.Range("C1").Value = "Source Data"
ActiveSheet.Range("D1").Value = "Cache Index"

Range("A1").Select

'Go through one Worksheet at a time
For Each wksht In Worksheets
For Each PivTbl In wksht.PivotTables
iRow = iRow + 1
ActiveCell.Offset(iRow, 0).Value = wksht.Name
ActiveCell.Offset(iRow, 1).Value = PivTbl.Name
ActiveCell.Offset(iRow, 2).Value = _
PivTbl.SourceData
ActiveCell.Offset(iRow, 3).Value = _
PivTbl.CacheIndex
Next PivTbl
Next wksht

Cells.EntireColumn.AutoFit
Range("A2").Select
ActiveWindow.FreezePanes = True

End Sub
'/=====================================/
Sub Change_My_CacheIndex()
Worksheets("Sheet1"). _
PivotTables("MyPivotTable").CacheIndex = 4
End Sub
'/=====================================/




"Don S" wrote:

When you build pivot tables, you are given the option to share source
data with an existingr pivot table (when applicable).

If this option was not selected when the workbook was developed, is
there a way to get pivot tables using the same data table to share the
cache - short of recreating them?

Thanks!
Don S

  #3   Report Post  
Don S
 
Posts: n/a
Default

Fantastic!!!!

Thanks, Gary.

It works great. It cut the time it takes to open and save the
workbook in half.

A side benefit I didn't expect was a tidy listing of the pivot tables
in my workbook and the source data tables they use. WOW!

Don S.

On Tue, 22 Mar 2005 11:09:01 -0800, "Gary Brown"
wrote:

Great Question!!!
The only way I can think to do this is to know what 'Cache Index' each pivot
table has. The CacheIndex is an identifier of the range of data used for
that pivot table.

To find out what cacheindex each of your pivot tables has, run the macro
below called "Pivot_Table_Information".

Once you've identified which pivot table has which Cache Index, run the
macro below called "Change_My_CacheIndex".
REMEMBER TO CHANGE THE EXAMPLE FOR THE ACTUAL WORKSHEET NAME AND PIVOT TABLE
NAME!!!

HTH,
Gary Brown

'/=====================================/
Sub Pivot_Table_Information()
Dim iRow As Long
Dim PivTbl As PivotTable
Dim wksht As Worksheet
On Error Resume Next

Worksheets.Add.Move _
After:=Worksheets(Worksheets.Count)

ActiveSheet.Range("A1").Value = "Worksheet"
ActiveSheet.Range("B1").Value = _
"Pivot Table Name"
ActiveSheet.Range("C1").Value = "Source Data"
ActiveSheet.Range("D1").Value = "Cache Index"

Range("A1").Select

'Go through one Worksheet at a time
For Each wksht In Worksheets
For Each PivTbl In wksht.PivotTables
iRow = iRow + 1
ActiveCell.Offset(iRow, 0).Value = wksht.Name
ActiveCell.Offset(iRow, 1).Value = PivTbl.Name
ActiveCell.Offset(iRow, 2).Value = _
PivTbl.SourceData
ActiveCell.Offset(iRow, 3).Value = _
PivTbl.CacheIndex
Next PivTbl
Next wksht

Cells.EntireColumn.AutoFit
Range("A2").Select
ActiveWindow.FreezePanes = True

End Sub
'/=====================================/
Sub Change_My_CacheIndex()
Worksheets("Sheet1"). _
PivotTables("MyPivotTable").CacheIndex = 4
End Sub
'/=====================================/




"Don S" wrote:

When you build pivot tables, you are given the option to share source
data with an existingr pivot table (when applicable).

If this option was not selected when the workbook was developed, is
there a way to get pivot tables using the same data table to share the
cache - short of recreating them?

Thanks!
Don S


  #4   Report Post  
Debra Dalgleish
 
Posts: n/a
Default

Another option is to change all pivot caches to match that of a
specified pivot table. There's sample code he

http://www.contextures.com/xlPivot11.html

Don S wrote:
When you build pivot tables, you are given the option to share source
data with an existingr pivot table (when applicable).

If this option was not selected when the workbook was developed, is
there a way to get pivot tables using the same data table to share the
cache - short of recreating them?

Thanks!
Don S



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #5   Report Post  
Don S
 
Posts: n/a
Default

Thanks Debra,

That would work well when there is only one data source in the
workbook. I have to selectively change each pivot table cache since
my 30+ pivot tables use one of 8 different data tables in the same
workbook.

I can use this method in other workbooks, though. I built several "on
the fly" and am now trying to clean them up.

Thank you,

Don S

On Tue, 22 Mar 2005 15:43:12 -0500, Debra Dalgleish
wrote:

Another option is to change all pivot caches to match that of a
specified pivot table. There's sample code he

http://www.contextures.com/xlPivot11.html

Don S wrote:
When you build pivot tables, you are given the option to share source
data with an existingr pivot table (when applicable).

If this option was not selected when the workbook was developed, is
there a way to get pivot tables using the same data table to share the
cache - short of recreating them?

Thanks!
Don S


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
Need Formula to display pivot table source data Don S Excel Worksheet Functions 3 February 23rd 05 10:13 PM
Pivot Table Auto Update Data Source? Ket Excel Worksheet Functions 1 February 18th 05 11:14 PM
Pivot tables, external data sources and ODBC links plato Excel Worksheet Functions 0 January 17th 05 05:07 PM
Pivot Tables referring to external data query Excel GuRu Excel Discussion (Misc queries) 4 December 29th 04 06:29 PM
pivot table in data source order Murray Excel Discussion (Misc queries) 1 December 24th 04 09:01 PM


All times are GMT +1. The time now is 05:42 AM.

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

About Us

"It's about Microsoft Excel"