Hello All,
The code below is attempting to create a pivot table based on a table of data in a different sheet. The error is "Run-time error '5' Invalid Procedure Call or Argument." Please see the code below. I can post additional lines as well, but the failure occurs on the "set pt = ..." command. Thank you in advance.
Code
Dim ws As Worksheet, pt As PivotTable, pc As PivotCaches, pRange As Range
Set ws = Worksheets("Pivot Table")
Set pRange = Worksheets("Input").Range("A1").CurrentRegion
Set pt = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=pRange, _
Version:=xlPivotTableVersion15).createPivotTable(TableDestination:=ws.Range("A1"), _
TableName:="pt", DefaultVersion:=xlPivotTableVersion15)