Hello there. I run a macro each week which analyses some data. It works fine until I try to stick the data into a Pivot Table
The size of the data range changes, so I give it a name and I'm trying to use the named range as the data source for the Table. I'm getting an error which I think relates to the SourceData statement....
The data range is selected, then.....
Dim PivRange As Range
Set PivRange = Selection
ActiveWorkbook.Names.Add Name:="PivRange", RefersToR1C1:=Selection
ActiveWorkbook.Names("PivRange").Comment = ""
'----> this next line (which was mostly from the Macro-recorder) won't execute;
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"'Loan Book'!PivRange", Version:=xlPivotTableVersion15).CreatePivotTable _
TableDestination:="Loan Book!R2C26", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion15
Any ideas please?
John Downes
The size of the data range changes, so I give it a name and I'm trying to use the named range as the data source for the Table. I'm getting an error which I think relates to the SourceData statement....
The data range is selected, then.....
Dim PivRange As Range
Set PivRange = Selection
ActiveWorkbook.Names.Add Name:="PivRange", RefersToR1C1:=Selection
ActiveWorkbook.Names("PivRange").Comment = ""
'----> this next line (which was mostly from the Macro-recorder) won't execute;
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"'Loan Book'!PivRange", Version:=xlPivotTableVersion15).CreatePivotTable _
TableDestination:="Loan Book!R2C26", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion15
Any ideas please?
John Downes