ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing Pivot Table Source Data (https://www.excelbanter.com/excel-programming/426899-changing-pivot-table-source-data.html)

Barb Reinhardt

Changing Pivot Table Source Data
 
I'm trying to change the source data for a pivot table and am using this syntax

myPivot.SourceData = myString

where

mystring = 'ALL ITEMS'!all_items

I'm getting a run time error 1004, reference is not valid.

I'm not sure what the problem might be. Can someone assist?

Thanks,
Barb Reinhardt

Patrick Molloy[_2_]

Changing Pivot Table Source Data
 
this works for me...

Sub set_two()
Dim pc As PivotCache
Dim pt As PivotTable
Set pt = Sheet1.PivotTables(1)
With pt
.SourceData = "'ALL ITEMS'!all_items"
.RefreshTable
End With
End Sub

i was able to raise error 1004 by using a range name that didn't exist - ie
mis-typing the name

Patrick Moloy

"Barb Reinhardt" wrote:

I'm trying to change the source data for a pivot table and am using this syntax

myPivot.SourceData = myString

where

mystring = 'ALL ITEMS'!all_items

I'm getting a run time error 1004, reference is not valid.

I'm not sure what the problem might be. Can someone assist?

Thanks,
Barb Reinhardt



All times are GMT +1. The time now is 05:23 PM.

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