Hello all
I have recorded the macro below to create a Pivot table, however I would like to use this again without having to record it. The problem I have is the the Pivot table report can be a variable length, sometime 10 rows or sometimes hundreds of row.
Below is the code, the second set of code is what I would like it to do but keep getting error messages.
Any help is appreciated.
Thanks
I have recorded the macro below to create a Pivot table, however I would like to use this again without having to record it. The problem I have is the the Pivot table report can be a variable length, sometime 10 rows or sometimes hundreds of row.
Below is the code, the second set of code is what I would like it to do but keep getting error messages.
Code:
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'Completed'!R1C1:R311C8").CreatePivotTable TableDestination:="", _
TableName:="PivotTable2", DefaultVersion:=xlPivotTableVersion10
Code:
LastRow = ActiveSheet.UsedRange.Rows.Count
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'Work Outstanding'!A1:H & LastRow").CreatePivotTable TableDestination:="", _
TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
Any help is appreciated.
Thanks