Share via

changing source data of pivot table

Anonymous
2012-04-24T21:59:08+00:00

Hi All,

I get a message when trying to change source data of pivot table with this line:

    ActiveSheet.PivotTables("pivotname").ChangePivotCache _

        ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _

        "DUMP!R1C1:R" & Dumpcount & "C25", Version:= _

        xlPivotTableVersion14)

The message:

"Do you want to replace the contents of the destination cells in [workbook_name]sheet_name?

Yes/No"

[workbook_name]sheet_name is the sheet where the pivot table is located.

The columns of the pivot table disappear either if I reply Yes or No.

As far as I could observe the column structure of the source did not change, only the number of rows has increased.

Why does this happen and how can I avoid it. What do I do wrong, what did not I notice?

Thanks,

Stefi

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-04-28T20:01:43+00:00

I got an answer to the first part of the problem on http://social.technet.microsoft.com/Forums/en-US/excel/threads from Learning and Learning, and finally figured out the answer to the second part myself.

The cause of disappearing columns was this, maybe it is of interest also for other people: Some of the column headers had a redundant trailing space. When the pivot table was built Excel put these headers into the field list trimmed, but when datasource was changed to another range with the same headers with redundant trailing spaces Excel tried to match the trimmed field names and the untrimmed headers, found they are different and removed pivot table columns. Trimming headers before changing  datasource resolved the problem.

Stefi

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2012-04-25T10:54:21+00:00

    For issues related to Pivot tables you may also post your question and queries on the link below.

    http://social.technet.microsoft.com/Forums/en-US/excel/threads

    Was this answer helpful?

    0 comments No comments