I've created a program that copies over a pivot table from another workbook, but I need it to refer to the worksheet in the current file.
So for example, in the original file it refers to "QueryResults" as the source, and I need it to refer to the "QueryResults" in the new file after it is transferred over. Does anyone have any ideas on how to do this?
I've tried unsuccessfully to recreate the cache, but get an error when running it in my code.
ActiveWorkbook.PivotCaches.Create _
(SourceType:=xlDatabase, SourceData:=Worksheets("QueryResults").Range("A1:AY" & _
Worksheets("QueryResults").Cells(Rows.Count, 1).End(xlUp).Row).Address(External:=True), _
Version:=xlPivotTableVersion14)