ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change SourceData in Excel PivotTable via VBA (https://www.excelbanter.com/excel-programming/294613-change-sourcedata-excel-pivottable-via-vba.html)

CarlsonClan

Change SourceData in Excel PivotTable via VBA
 
I am updating a number of files that all require the same pivot table
so I am copying a "standard" pivot table (actually, the whole workshee
the pivot table is in) from one file and pasting it to each file. A
this point, all I want to do is update the SourceData to reflect
named region ("RawData") in each file.

The following gives me an error:

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, _
SourceData:="RawData"
ActiveSheet.PivotTables("RT Data").PivotCache.Refresh

The pivot table is called "RT Data", so that is not the error. Doe
anyone have any suggestions

--
Message posted from http://www.ExcelForum.com


Debra Dalgleish

Change SourceData in Excel PivotTable via VBA
 
What error do you get, and which line is highlighted?

CarlsonClan < wrote:
I am updating a number of files that all require the same pivot table,
so I am copying a "standard" pivot table (actually, the whole worksheet
the pivot table is in) from one file and pasting it to each file. At
this point, all I want to do is update the SourceData to reflect a
named region ("RawData") in each file.

The following gives me an error:

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, _
SourceData:="RawData"
ActiveSheet.PivotTables("RT Data").PivotCache.Refresh

The pivot table is called "RT Data", so that is not the error. Does
anyone have any suggestions?


--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 02:38 PM.

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