显示数据透视表的缓存索引
当一个工作簿中有一个以上的数据透视表时,使用下列函数可以显示各个数据透视表的缓存索引(建数据透视表的先后顺序编号).放置函数代码到工作表模块中.
然后在工作表单元格中输入下列公式:
=ShowCacheIndex(A3)
用数据透视表的其它单元格替换A3.
Function ShowCacheIndex(rngPT As Range) As Long
ShowCacheIndex = rngPT.PivotTable.CacheIndex
End Function
缓存使用量 你可以使用下列函数显示数据透视表使用的缓存量. 放置函数代码到工作表模块中. 然后在工作表单元格中输入下列公式:: =GetMemory(A3)/1000
用数据透视表的其它单元格替换A3. 显示的结果单位是千字节(kb). Function GetMemory(rngPT As Range) As Long Dim pt As PivotTable Set pt = rngPT.PivotTable GetMemory = ActiveWorkbook _ .PivotCaches(pt.CacheIndex).MemoryUsed End Function
|
显示数据透视缓存中的记录数 你可以使用下列函数显示数据透视表在缓存中的记录数. 放置函数代码到工作表模块中. 然后在工作表单元格中输入下列公式:: =GetRecords(A3)
用数据透视表的其它单元格替换A3. Function GetRecords(rngPT As Range) As Long Dim pt As PivotTable Set pt = rngPT.PivotTable GetRecords = ActiveWorkbook _ .PivotCaches(pt.CacheIndex).RecordCount End Function
|
改变数据透视缓存 如果你在一个工作簿中创建了数个数据透视表, 你也许会发现它会尽可能的在不同数据透视表中使用同一个数据透视缓存. 下面代码将改变工作簿中每个数据透视表的数据透视缓存. Sub ChangePivotCache() '改变工作簿中所有数据透视表的数据透视缓存 Dim pt As PivotTable Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets For Each pt In wks.PivotTables pt.CacheIndex = Sheets("Pivot").PivotTables(1).CacheIndex Next pt Next wks End Sub
|