Excel VBA corrupting Pivot Tables

S

Scott MacIntyre

Im using command buttons to activate VBA code which drives
a pivot table.

If the pivotitem field is set to (All) I get "run time
error 1004 unable to set the _default property of the
pivotitem class". I found this documented as Microsoft
Knowledge Base Article - 177527 - which provides 3
workarounds for this problem - however none of them have
worked. In addition if the pivotitem field is not set to
(All) and the command button is clicked, the VBA corrupts
the pivotitem field overwriting the previously shown field
item with that selected.

For example :

Before After
------ -----
Item1 (All) Item1 (All)
Item2 Bananas Item2 Pears

If you look at the drop down lists for the pivot table in
the Before status it lists the 4 options

Apples
Bananas
Oranges
Pears

However after using the commend button to pivot the table
using VBA the dropdown list duplicates/overwrites that
pivotitem fiels so that the list now appears incorrectly
as

Apples
Pears <------------------ offending item
Oranges
Pears

And so the pivot table becomes corrupted.

Please does anyone known of a workaround for this issue as
its driving me not so slowly nuts :)

Cheers,

Scott

p.s. Im using XL 97 with Office service pack 2 installed
on an NT4 pc with NT service pack 6 installed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top