PC Review


Reply
Thread Tools Rate Thread

Can I add an item to a PivotCache with VBA?

 
 
John Brock
Guest
Posts: n/a
 
      16th Jun 2008
If I create a pivot table using a database which contains a particular
value, let's say "3", and then I change all the 3s to something
else, the pivot table remembers the missing value. I.e., if I
check the "Show items with no data" checkbox for that field, the
pivot table will contain a column called "3" even though there are
no 3s any more. What's more, that column will continue to appear
even after I refresh the pivot table. In fact, the only way I can
make that column go away permanently is by calling PivotItems("3").Delete()
from VBA. (Is there a way to do this manually?)

However if I try to add a PivotItem to the table using VBA I can
do it, but the added column disappears the minute I do a refresh.
The best I can figure is that adding a PivotItem to the table
doesn't touch the cache, while adding data to the database does,
even after that data has been deleted.

So is there any way I can tell the pivot cache (not the pivot
table!) to add a new item? Deleting the item from the table seems
to affect the cache, but there doesn't seem to be any obvious way
to add items.

(I suppose I could add rows containing the desired values to the
database, refresh the pivot table, and then remove the added rows,
but that seems really hackish, and I'd much rather do it directly).
--
John Brock
(E-Mail Removed)

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      16th Jun 2008
Debra Dalgleish has some instructions here:
http://contextures.com/xlPivot04.html

John Brock wrote:
>
> If I create a pivot table using a database which contains a particular
> value, let's say "3", and then I change all the 3s to something
> else, the pivot table remembers the missing value. I.e., if I
> check the "Show items with no data" checkbox for that field, the
> pivot table will contain a column called "3" even though there are
> no 3s any more. What's more, that column will continue to appear
> even after I refresh the pivot table. In fact, the only way I can
> make that column go away permanently is by calling PivotItems("3").Delete()
> from VBA. (Is there a way to do this manually?)
>
> However if I try to add a PivotItem to the table using VBA I can
> do it, but the added column disappears the minute I do a refresh.
> The best I can figure is that adding a PivotItem to the table
> doesn't touch the cache, while adding data to the database does,
> even after that data has been deleted.
>
> So is there any way I can tell the pivot cache (not the pivot
> table!) to add a new item? Deleting the item from the table seems
> to affect the cache, but there doesn't seem to be any obvious way
> to add items.
>
> (I suppose I could add rows containing the desired values to the
> database, refresh the pivot table, and then remove the added rows,
> but that seems really hackish, and I'd much rather do it directly).
> --
> John Brock
> (E-Mail Removed)


--

Dave Peterson
 
Reply With Quote
 
John Brock
Guest
Posts: n/a
 
      16th Jun 2008
Thank you for a useful page. Alas though, it only explains how to
clear old items from a pivot cache. I want to add new "old" items,
without the runaround of adding and then deleting records from the
database.

In article <(E-Mail Removed)>,
Dave Peterson <(E-Mail Removed)> wrote:
>Debra Dalgleish has some instructions here:
>http://contextures.com/xlPivot04.html


>John Brock wrote:
>>
>> If I create a pivot table using a database which contains a particular
>> value, let's say "3", and then I change all the 3s to something
>> else, the pivot table remembers the missing value. I.e., if I
>> check the "Show items with no data" checkbox for that field, the
>> pivot table will contain a column called "3" even though there are
>> no 3s any more. What's more, that column will continue to appear
>> even after I refresh the pivot table. In fact, the only way I can
>> make that column go away permanently is by calling PivotItems("3").Delete()
>> from VBA. (Is there a way to do this manually?)
>>
>> However if I try to add a PivotItem to the table using VBA I can
>> do it, but the added column disappears the minute I do a refresh.
>> The best I can figure is that adding a PivotItem to the table
>> doesn't touch the cache, while adding data to the database does,
>> even after that data has been deleted.
>>
>> So is there any way I can tell the pivot cache (not the pivot
>> table!) to add a new item? Deleting the item from the table seems
>> to affect the cache, but there doesn't seem to be any obvious way
>> to add items.
>>
>> (I suppose I could add rows containing the desired values to the
>> database, refresh the pivot table, and then remove the added rows,
>> but that seems really hackish, and I'd much rather do it directly).
>> --
>> John Brock
>> (E-Mail Removed)

>
>--
>
>Dave Peterson



--
John Brock
(E-Mail Removed)

 
Reply With Quote
 
Qaiser96
Guest
Posts: n/a
 
      16th Jun 2008
Click on the Pivot Table and then do Right click and select the refresh
option. This would help the pivot table to take the effect of the changes you
have made to the database....

--
Qaiser


"John Brock" wrote:

> If I create a pivot table using a database which contains a particular
> value, let's say "3", and then I change all the 3s to something
> else, the pivot table remembers the missing value. I.e., if I
> check the "Show items with no data" checkbox for that field, the
> pivot table will contain a column called "3" even though there are
> no 3s any more. What's more, that column will continue to appear
> even after I refresh the pivot table. In fact, the only way I can
> make that column go away permanently is by calling PivotItems("3").Delete()
> from VBA. (Is there a way to do this manually?)
>
> However if I try to add a PivotItem to the table using VBA I can
> do it, but the added column disappears the minute I do a refresh.
> The best I can figure is that adding a PivotItem to the table
> doesn't touch the cache, while adding data to the database does,
> even after that data has been deleted.
>
> So is there any way I can tell the pivot cache (not the pivot
> table!) to add a new item? Deleting the item from the table seems
> to affect the cache, but there doesn't seem to be any obvious way
> to add items.
>
> (I suppose I could add rows containing the desired values to the
> database, refresh the pivot table, and then remove the added rows,
> but that seems really hackish, and I'd much rather do it directly).
> --
> John Brock
> (E-Mail Removed)
>
>

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      16th Jun 2008
A pivot table doesn't allow display of data that doesn't (or didn't) come
from the source database.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"John Brock" <(E-Mail Removed)> wrote in message
news:g34m2p$3o9$(E-Mail Removed)...
> Thank you for a useful page. Alas though, it only explains how to
> clear old items from a pivot cache. I want to add new "old" items,
> without the runaround of adding and then deleting records from the
> database.
>
> In article <(E-Mail Removed)>,
> Dave Peterson <(E-Mail Removed)> wrote:
>>Debra Dalgleish has some instructions here:
>>http://contextures.com/xlPivot04.html

>
>>John Brock wrote:
>>>
>>> If I create a pivot table using a database which contains a particular
>>> value, let's say "3", and then I change all the 3s to something
>>> else, the pivot table remembers the missing value. I.e., if I
>>> check the "Show items with no data" checkbox for that field, the
>>> pivot table will contain a column called "3" even though there are
>>> no 3s any more. What's more, that column will continue to appear
>>> even after I refresh the pivot table. In fact, the only way I can
>>> make that column go away permanently is by calling
>>> PivotItems("3").Delete()
>>> from VBA. (Is there a way to do this manually?)
>>>
>>> However if I try to add a PivotItem to the table using VBA I can
>>> do it, but the added column disappears the minute I do a refresh.
>>> The best I can figure is that adding a PivotItem to the table
>>> doesn't touch the cache, while adding data to the database does,
>>> even after that data has been deleted.
>>>
>>> So is there any way I can tell the pivot cache (not the pivot
>>> table!) to add a new item? Deleting the item from the table seems
>>> to affect the cache, but there doesn't seem to be any obvious way
>>> to add items.
>>>
>>> (I suppose I could add rows containing the desired values to the
>>> database, refresh the pivot table, and then remove the added rows,
>>> but that seems really hackish, and I'd much rather do it directly).
>>> --
>>> John Brock
>>> (E-Mail Removed)

>>
>>--
>>
>>Dave Peterson

>
>
> --
> John Brock
> (E-Mail Removed)
>



 
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
Can I add an item to a PivotCache with VBA? John Brock Microsoft Excel Programming 4 16th Jun 2008 01:00 PM
PivotCache =?Utf-8?B?VC4=?= Microsoft Excel Programming 1 18th Aug 2006 10:17 PM
Pivotcache Pivot Table Pete Microsoft Excel Programming 1 5th Aug 2006 12:38 PM
PivotCache Nick Microsoft Excel Misc 0 31st Jul 2003 05:13 PM
PivotCache Question John Michl Microsoft Excel Worksheet Functions 1 10th Jul 2003 11:09 PM


Features
 

Advertising
 

Newsgroups
 


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