LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Deleting "old items" bug with pivot cache

Hi,

That's a tricky one, so seat down, take a deep breath and enjoy...

I've been using the following code successfully to delete old items
from the Pivot Tables I use.

Sub DeleteOldItemsWB()
'gets rid of unused items in PivotTable
' based on MSKB (Q202232)
Dim ws As Worksheet
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim i As Integer

On Error Resume Next
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
For Each pf In pt.PivotFields
For Each pi In pf.PivotItems
If pi.RecordCount = 0 And _
Not pi.IsCalculated Then
pi.Delete
End If
Next
Next
Next
Next
End Sub

....this has never been a problem until I decided to optimise the size
of my excel file by following the method below:
http://groups.google.com/groups?q=au...7th.com&rnum=4
(basicallly this sets all the table to point to the same cache and
then disable cache saving).

The problem I encounter now is as follows:
- excel tries to delete items which are actually existing (i.e. where
pi.recordcount 0 !!!). The Macro crashes and excel too! Even more
irritable is that the error is random (or at least tend to allow me to
perform the operation once and then crashes afterward)

So I have tried the following solutions/workarounds:
- re-enable cache saving (enabling table option "Save data with table
layout")
- no success
- Steping through the code
- works great! (no so practical though, especially if you don't have
access to the code)
- save workbook, Restart Excel2000/win2000
- no success
- included wait state in the code
- no success

Could that be a pivot cache corruption problem?...

Good luck to you all and thanks in advance!

PS: I could send you a sample of my file if you were interested.
 
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
Pivot (Data Items "Count" vs "Sum") Ken Excel Discussion (Misc queries) 2 November 11th 09 12:46 PM
Deleting Items on Spreadsheet produced from "Draw" toolbar F. Lawrence Kulchar Excel Discussion (Misc queries) 2 November 27th 08 07:20 PM
How do I move a document from "recent items" to "documents" John Gerke in Central Oregon New Users to Excel 1 March 2nd 08 08:31 AM
Pivot "row hide menu" keeps having items I don't have anymore!?!? [email protected] Excel Discussion (Misc queries) 6 January 4th 07 11:27 PM
Pivot Table "Include hidden items in totals" LizO Excel Discussion (Misc queries) 0 March 14th 06 07:37 PM


All times are GMT +1. The time now is 07:37 PM.

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"