View Single Post
  #1   Report Post  
cqc
 
Posts: n/a
Default Source Data in Pivot Tables

Every week I run a macro to create a pivot table, using source data whose
table size varies weekly, coded as follows:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Sheet1!WklyTblSz").CreatePivotTable TableDestination:="", TableName _
:="PivotTable2"

Before running the macro, I would go to the source data to change the cell
references for the 'WklyTblSz' worksheet, using INSERTNAMEDEFINE.

Is there code I can use so that the references are adjusted depending on the
last row and column for the weekly input file?

Thanks in advance,
cqc