ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change SourceName on Pivot Table (https://www.excelbanter.com/excel-programming/445427-change-sourcename-pivot-table.html)

Steve[_4_]

Change SourceName on Pivot Table
 
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


All times are GMT +1. The time now is 10:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com