Help!

Pivot Table - Remove Calculated Item

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Excel General (archive) RSS
Next:  Excel 2003 security  
Author Message
pbbellri



Joined: Sep 24, 2008
Posts: 4

Location: Chicago, IL

PostPosted: Tue Sep 30, 2008 4:45 pm    Post subject: Pivot Table - Remove Calculated Item

I accidentally inserted CALCULATED FIELD into my pivot row instead if inserting CALCULATED FIELD in the data area. Have a month "Formula1" made the pivot look bad and it was cumbersome to HIDE that item on each pivot copy. How do I remove or delete it from the pivot's cache memory?

I didn't find any direct answer with a quick search, but I did figure something out, and thus I'm posting the answer here.

I tried a macro from the following website to clear the cache, but it didn't quite work (it works when the data source used to actually have an item, but not for items inserted using the INSERT CALCULATED FIELD option).

http://www.contextures.com/xlPivot04.html

Code:

Sub DeleteMissingItems2002All()
'prevents unused items in non-OLAP PivotTables

Dim pt As PivotTable
Dim ws As Worksheet
Dim pc As PivotCache

'change the settings
For Each ws In ActiveWorkbook.Worksheets
  For Each pt In ws.PivotTables
    pt.PivotCache.MissingItemsLimit = xlMissingItemsNone
  Next pt
Next ws

'refresh all the pivot caches
For Each pc In ActiveWorkbook.PivotCaches
  On Error Resume Next
  pc.Refresh
Next pc

End Sub


So tried using whatever command I could think of and found out that the PIVOTITEM property worked. The field I had inserted was in cell B16, so I used the following code to delete it... then ran the above code to clear the cache.

Code:

Sub RemoveItem()
  Range("B16").PivotItem.Delete
End Sub


It worked.

--Paul
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Excel General (archive) All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum