excel - Share PivotCache for PivotTables built with data model -


i cleaning workbook , have used following code consolidate pivotcaches (i had around 200 prior cleaning).

sub changecache() dim ws worksheet dim pt pivottable dim pc pivotcache dim first boolean on error resume next      each ws in activeworkbook.worksheets         ws.activate         each pt in activesheet.pivottables              if first = false                 set pc = pt.pivotcache                 first = true             end if               pt.cacheindex = pc.index          next pt     next ws  end sub 

this has reduced pivotcache count 33.

sub countcaches()   msgbox activeworkbook.pivotcaches.count end sub 

the reason 33 , not 1 because have 32 pivottables built data model.

my question is: know how change pivottables built data model use same pivotcache?

edit

my secondary question is: multiple pivot tables built on data model

a) reference single data model; or

b) each have own model , therefore 'bloat' excel file

edit2

on further exploration, appears data model is shared pivot tables reference same data. can seen in 'connections' (found under 'data' tab in ribbon). in theory, shouldn't 'bloat' file though code activeworkbook.pivotcaches.count counts each pivot table shares connection , falsely(?) indicates multiple caches.

i leave bounty open in case can provide more definitive answer.

if understand question correctly, have set each pc first one. so, first pass, give pc other name such pcfirst, each remaining cache, set pc=pcfirst. source information here http://www.contextures.com/xlpivot11.html , here http://www.mrexcel.com/forum/excel-questions/380933-set-multiple-pivot-cache-read-one-cache.html


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -