![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
.
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
|
How does a PivotCache get deleted from memory?
I have a procedure that defines a pivot cache and builds two pivot tables. Another procedure modifies the pivot tables. When that procedure is complete, it clears the pivot tables with Code:
PT.TableRange2.Clear
PT2.TableRange2.Clear
After deleting the above pivot tables, this code seems to indicate that the PivotCache is gone. There are no messages generated from this: Code:
For Each pc In ActiveWorkbook.PivotCaches
MsgBox pc.MemoryUsed
Next pc
Bill _________________ MrExcel.com Consulting [ This Message was edited by: MrExcel on 2002-05-17 06:53 ] |
|
|
|
|
|
#2 |
|
.
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
|
I added Debug.Print Application.MemoryUsed at the beginning and end of the report.
Even though there are no PivotCaches left in ActiveWorkbook.PivotCaches, I'm clearly taking up a significant higher amount of memory. Any ideas on how to clear the MemoryUsed?
__________________
Preview my latest book for Free |
|
|
|
|
|
#3 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Is the following of help?
Pulled from: http://www.microsoft.com/exceldev/articles/movs104.htm |
|
|
|
|
|
#4 |
|
.
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
|
I saw that and was able to ascertain the memory being used by the PivotCache. You'll notice they don't address clearing the PivotCache at all.
I am tempted to try creating the pivot table in a temporary workbook. Then, after creating the report, I could close that temporary workbook, which should remove any memory used by that temporary workbook...
__________________
Preview my latest book for Free |
|
|
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
The temp file may be the way to go, I'm starting to get the impression that the pivotcache object is read-only. A few findings:
The following link has a lot of useful object property details, including .optimizecache but I didn't notice anything regarding deletion. http://msdn.microsoft.com/library/de...pivotcache.asp I did stumble into the following. Per Microsoft: "Remarks If the PivotTable cache isn?t referenced by a PivotTable object, the PivotTable cache is automatically deleted before the workbook is saved." http://216.239.39.100/search?q=cache...&hl=en&ie=UTF8 Section: Add method as it applies to the PivotCaches object. From this I might surmize that if one deletes a pivot table, the cache is deleted and until then it's out there. Perhaps XL can be of assistance. _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-05-17 13:34 ] |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
What happens when you do this...
ActiveSheet.PivotTables("PivotTable1").SaveData = False |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|