I'm trying to create a Pivot table, but getting Invalid Procedure Call or Argument.
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="rng", Version:=xlPivotTableVersion14).CreatePivotTable TableDestination:="rngB", TableName:="pvtReportA_B", DefaultVersion:=xlPivotTableVersion14
- rng(The source) is a range consisting of about 20 columns and a few thousand rows.
- rngB(The destination) is a single cell in a different worksheet
Can anyone advise where I am going wrong?
EDIT:
My fault, I should have been using rngData and not rng as the Source.
    Set rng = wsA.Range("C14")
    Set rngData = Range(rng, rng.End(xlToRight))
    Set rngData = Range(rng, rng.End(xlDown))
    Set rngB = wsB.Range("C8")
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=rngData, Version:=xlPivotTableVersion14).CreatePivotTable TableDestination:=rngB, TableName:="pvtReportA_B", DefaultVersion:=xlPivotTableVersion14
This brings up the PivotTable frame just fine.
 
     
    