PC Review


Reply
Thread Tools Rate Thread

Debra Dalgleish's clearing old items from Pivot Table dropdowns

 
 
Andrew
Guest
Posts: n/a
 
      21st Feb 2008
Hi.

I was hoping to direct this question directly to Debra as she wrote the code
but if anyone else can assist feel free to reply.


I used the code on http://www.contextures.com/xlPivot04.html (I'm using
Excel 2000) to clear old items from the drop-downs. It took over 30 minutes
to complete.

On completion I clicked on a drop-down and Excel shut down - frustrating!!
I repeated this procedure, saved the file on completion, closed the file and
then tried to re-open the file. Again the file caused Excel to shut-down,
this time before the file opened.

Have you ever experienced this?

I also tried the manual way suggested. Although it didn't crash it didn't
get rid of the old items.

I should also point out there are approximately 10 worksheets within the
workbook, with the majority haveing a pivot table on them. I took your (and
others) advice and used the same data to use less data. Does this create a
problem?

Any suggestions would be greatly appreciated.




--
Andrew
 
Reply With Quote
 
 
 
 
Debra Dalgleish
Guest
Posts: n/a
 
      22nd Feb 2008
The code loops through all the pivot items in each visible pivot fields,
so it will be slow if there are many pivot items/fields.
For pivot tables based on the same pivot cache, you could just run the
code on one pivot table, and all the connected pivot tables would be
updated.
For the manual method to work, you'd have to remove the field from all
copies of the pivot table that share the same pivot cache, then refresh
the pivot table.

'====================
Sub DeleteOldItems_PT()
'gets rid of unused items in PivotTable
' based on MSKB (202232)
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

On Error Resume Next
Set pt = ActiveSheet.PivotTables(1)
pt.RefreshTable
pt.ManualUpdate = True
For Each pf In pt.VisibleFields
If pf.Name <> "Data" Then
For Each pi In pf.PivotItems
If pi.RecordCount = 0 And _
Not pi.IsCalculated Then
pi.Delete
End If
Next pi
End If
Next pf
pt.ManualUpdate = False
pt.RefreshTable
Set pt = Nothing
End Sub
'============================

Andrew wrote:
> Hi.
>
> I was hoping to direct this question directly to Debra as she wrote the code
> but if anyone else can assist feel free to reply.
>
>
> I used the code on http://www.contextures.com/xlPivot04.html (I'm using
> Excel 2000) to clear old items from the drop-downs. It took over 30 minutes
> to complete.
>
> On completion I clicked on a drop-down and Excel shut down - frustrating!!
> I repeated this procedure, saved the file on completion, closed the file and
> then tried to re-open the file. Again the file caused Excel to shut-down,
> this time before the file opened.
>
> Have you ever experienced this?
>
> I also tried the manual way suggested. Although it didn't crash it didn't
> get rid of the old items.
>
> I should also point out there are approximately 10 worksheets within the
> workbook, with the majority haveing a pivot table on them. I took your (and
> others) advice and used the same data to use less data. Does this create a
> problem?
>
> Any suggestions would be greatly appreciated.
>
>
>
>



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

 
Reply With Quote
 
Andrew
Guest
Posts: n/a
 
      22nd Feb 2008
Hi Debra,

Thanks for the reply.

I'm running your code now but it is now 2 hours into it and still going. I
break into the code (using ESC) every 15 min or so and you can see it is
progressing but gee it takes a long time.

Can you please advise why values in the drop-downs are kept. It seems such
a logical requirement yet it isn't a feature. The cache must be taking up
space in memory, affecting performance.

BTW your name is very represented on sites regarding pivot tables. Keep up
the good work.

Andrew 220208



--
Andrew


"Debra Dalgleish" wrote:

> The code loops through all the pivot items in each visible pivot fields,
> so it will be slow if there are many pivot items/fields.
> For pivot tables based on the same pivot cache, you could just run the
> code on one pivot table, and all the connected pivot tables would be
> updated.
> For the manual method to work, you'd have to remove the field from all
> copies of the pivot table that share the same pivot cache, then refresh
> the pivot table.
>
> '====================
> Sub DeleteOldItems_PT()
> 'gets rid of unused items in PivotTable
> ' based on MSKB (202232)
> Dim pt As PivotTable
> Dim pf As PivotField
> Dim pi As PivotItem
>
> On Error Resume Next
> Set pt = ActiveSheet.PivotTables(1)
> pt.RefreshTable
> pt.ManualUpdate = True
> For Each pf In pt.VisibleFields
> If pf.Name <> "Data" Then
> For Each pi In pf.PivotItems
> If pi.RecordCount = 0 And _
> Not pi.IsCalculated Then
> pi.Delete
> End If
> Next pi
> End If
> Next pf
> pt.ManualUpdate = False
> pt.RefreshTable
> Set pt = Nothing
> End Sub
> '============================
>
> Andrew wrote:
> > Hi.
> >
> > I was hoping to direct this question directly to Debra as she wrote the code
> > but if anyone else can assist feel free to reply.
> >
> >
> > I used the code on http://www.contextures.com/xlPivot04.html (I'm using
> > Excel 2000) to clear old items from the drop-downs. It took over 30 minutes
> > to complete.
> >
> > On completion I clicked on a drop-down and Excel shut down - frustrating!!
> > I repeated this procedure, saved the file on completion, closed the file and
> > then tried to re-open the file. Again the file caused Excel to shut-down,
> > this time before the file opened.
> >
> > Have you ever experienced this?
> >
> > I also tried the manual way suggested. Although it didn't crash it didn't
> > get rid of the old items.
> >
> > I should also point out there are approximately 10 worksheets within the
> > workbook, with the majority haveing a pivot table on them. I took your (and
> > others) advice and used the same data to use less data. Does this create a
> > problem?
> >
> > Any suggestions would be greatly appreciated.
> >
> >
> >
> >

>
>
> --
> Debra Dalgleish
> Contextures
> http://www.contextures.com/tiptech.html
>
>

 
Reply With Quote
 
Debra Dalgleish
Guest
Posts: n/a
 
      23rd Feb 2008
Perhaps the old items were kept so the user could see them, even if they
weren't in the current data.
If you enable the 'Show items with no data' option, you could quickly
see if any items were not in the new data. This might alert you to a
problem with a new download.

In Excel 2002, and later versions, you can set the number of missing
items that should be retained.

Andrew wrote:
> Hi Debra,
>
> Thanks for the reply.
>
> I'm running your code now but it is now 2 hours into it and still going. I
> break into the code (using ESC) every 15 min or so and you can see it is
> progressing but gee it takes a long time.
>
> Can you please advise why values in the drop-downs are kept. It seems such
> a logical requirement yet it isn't a feature. The cache must be taking up
> space in memory, affecting performance.
>
> BTW your name is very represented on sites regarding pivot tables. Keep up
> the good work.
>
> Andrew 220208
>
>
>



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debra Dalgleish - Pivot Tables (Change Multiple Page Fields) =?Utf-8?B?bW9saW5hcmFt?= Microsoft Excel Programming 3 15th Jun 2007 09:01 PM
Help with Debra Dalgleish's Code prkhan56@gmail.com Microsoft Excel Programming 18 20th Feb 2007 12:28 AM
Debra Dalgleish =?Utf-8?B?bmM=?= Microsoft Excel Misc 14 12th May 2006 12:41 PM
Debra Dalgleish: Pivot Table problem =?Utf-8?B?TGVlIEh1bnRlcg==?= Microsoft Excel Programming 3 20th May 2005 08:38 PM
Question for Debra Dalgleish / Reply to a Pivot Table Question carl Microsoft Excel Worksheet Functions 1 8th Jun 2004 02:46 AM


Features
 

Advertising
 

Newsgroups
 


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