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
|