ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing PivotTable source (https://www.excelbanter.com/excel-programming/280542-changing-pivottable-source.html)

atakacs[_2_]

Changing PivotTable source
 
Folks

I'd like to programmatically change the source data of an existing
PivotTable...

Tried


Code:
--------------------
Activesheet.PivotTables("PivotTable1").SourceData = "PivotTable_Data"
--------------------


Where "PivotTable1" is an existing pivot table and "PivotTable_Data" a
valid named range... but this doesn't work...

Any suggestion ?

Regards

--alex



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Tom Ogilvy

Changing PivotTable source
 
Why not set the source to a named range originally, then redefine the
definition of the named range.

--
Regards,
Tom Ogilvy


atakacs wrote in message
...
Folks

I'd like to programmatically change the source data of an existing
PivotTable...

Tried


Code:
--------------------
Activesheet.PivotTables("PivotTable1").SourceData = "PivotTable_Data"
--------------------


Where "PivotTable1" is an existing pivot table and "PivotTable_Data" a
valid named range... but this doesn't work...

Any suggestion ?

Regards

--alex



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/




Ngalula Kachika Michel

Changing PivotTable source
 
Try this:

Private Sub Worksheet_Activate()
Worksheets("Base").Range("cellule").CurrentRegion. Name
= "cellule"
ActiveSheet.PivotTableWizard SourceType:=xlDatabase,
SourceData:="cellule"
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh
End Sub


-----Original Message-----
Folks

I'd like to programmatically change the source data of an

existing
PivotTable...

Tried


Code:
--------------------
Activesheet.PivotTables("PivotTable1").SourceData

= "PivotTable_Data"
--------------------


Where "PivotTable1" is an existing pivot table

and "PivotTable_Data" a
valid named range... but this doesn't work...

Any suggestion ?

Regards

--alex



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.


Dave Peterson[_3_]

Changing PivotTable source
 
I don't use PPT, but you may find some sample code here at Jon Peltier's site:

http://www.geocities.com/jonpeltier/Excel/XL_PPT.html


Ngalula Kachika Michel wrote:

Try this:

Private Sub Worksheet_Activate()
Worksheets("Base").Range("cellule").CurrentRegion. Name
= "cellule"
ActiveSheet.PivotTableWizard SourceType:=xlDatabase,
SourceData:="cellule"
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh
End Sub

-----Original Message-----
Folks

I'd like to programmatically change the source data of an

existing
PivotTable...

Tried


Code:
--------------------
Activesheet.PivotTables("PivotTable1").SourceData

= "PivotTable_Data"
--------------------


Where "PivotTable1" is an existing pivot table

and "PivotTable_Data" a
valid named range... but this doesn't work...

Any suggestion ?

Regards

--alex



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.


--

Dave Peterson



All times are GMT +1. The time now is 11:56 PM.

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