deleting a data field from a pivot table

C

Cathy B

I am trying to reduce the number of pivot table templates
that we use (have to maintain) in our nightly process
which refreshes pivot table information from SQL server.
I added extra fields in the data area hoping that I could
set orientation to xlHidden or delete them.

I am finding that xlHidden code executes but doesn't have
any effect. I can still see the columns. I have code to
delete columns which seems to work on columns created by a
formula but not for a "real field" column.

In the code below the first statement works - I'm guessing
because the ArrayEstFields(iSheetsw -1) is a calculated
field. The second line of code referes to an actual file
pulled from the SQL table and gives me the error -
"Application-defined or object-defined error"

Any ideas as to how to solve this would be greatly
appreciated.

Below is my code:

xlWB.ActiveSheet.PivotTables("PivotTable1").PivotFields
(ArrayEstFields(iSheetsw - 1)).Delete

xlWB.ActiveSheet.PivotTables("PivotTable1").PivotFields
(ArrayBookedFields(iSheetsw - 1)).Delete
 

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