Glory
Well-known Member
- Joined
- Mar 16, 2011
- Messages
- 640
Unless it's attached to a pivot table during its creation, I can't get a new pivotcache object to survive at all. What i'm reading seems to indicate that a pivot cache should survive at least until I've saved the workbook.
This is important because I've got more than 65000 rows of data that I need to pivot, and I'd prefer not to have to create a new table for every new sheet of data if I can possibly avoid it (adds ten seconds or more to the macro's runtime).
The messagebox returns zero, unless I use the createpivottable method in the same line as the pivotcaches.add statement. But like I said, I don't want to have to create a new pivot table.
I've been experimenting with the other properties and methods of the pivotcaches.add method, but so far, no luck getting the pivotcache to survive long enough to use the CacheIndexes method to assign my existing pivot table a new cache.
So what I've been trying to instead is change the SourceData property of the pivot table. VBA's help says that's a read/write property, but I can't figure out how to write to it.
Can anyone help me out with this?
This is important because I've got more than 65000 rows of data that I need to pivot, and I'd prefer not to have to create a new table for every new sheet of data if I can possibly avoid it (adds ten seconds or more to the macro's runtime).
Code:
ThisWorkbook.PivotCaches.Add _
(SourceType:=xlDatabase, _
SourceData:=Sheets("Sheet1").Range("A:J")
MsgBox ThisWorkbook.PivotCaches.Count
The messagebox returns zero, unless I use the createpivottable method in the same line as the pivotcaches.add statement. But like I said, I don't want to have to create a new pivot table.
I've been experimenting with the other properties and methods of the pivotcaches.add method, but so far, no luck getting the pivotcache to survive long enough to use the CacheIndexes method to assign my existing pivot table a new cache.
So what I've been trying to instead is change the SourceData property of the pivot table. VBA's help says that's a read/write property, but I can't figure out how to write to it.
Can anyone help me out with this?