I am trying to create a macro that takes data from one worksheet called "Item Transaction" and creates a pivot table on another worksheet called "Pivot Table". I record the macro fine. But when going to test it I erase the pivot table it created and rerun it and im getting an error : Run-Time error '5': Invalid procedure call or argument. Below is the code that is highlighted why i go to debug. Any insight here?
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Item Transaction!R1C1:R1048576C30", Version:=8).CreatePivotTable _
TableDestination:="Pivot Table!R1C1", TableName:="PivotTable1", _
DefaultVersion:=8
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Item Transaction!R1C1:R1048576C30", Version:=8).CreatePivotTable _
TableDestination:="Pivot Table!R1C1", TableName:="PivotTable1", _
DefaultVersion:=8