Change SourceName on Pivot Table

S

Steve

Hi All,

I have a pivot table, where one of the data source column headers
changes. When this happens, and I go to Refresh my pivot table, that
particular column is removed. After doing some research, it sounds
like I need to change the SourceName on that field to match the source
data column header. I tried the following, but got the error 'Unable
to change the Source Name property of the PivotField Class'. Any
ideas?

Sub test()

Set i = Worksheets("Consolidated").Range("M1") 'the data
source header cell that changes

Worksheets("Summary").PivotTables(1) _
.PivotFields("Category").SourceName = i


End Sub
 

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