Run-time error '5': Invalid procedure call or argument

VJVitale

New Member
Joined
Dec 16, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
I've tried all the solutions recommended in other posts, but still can't get this pivot table to run in my macro. Its a simple pivot table. It comes from a worksheet where I want to be able to dump data in the future to create weekly headcount reports. Here is the highlighted coded when I click on the debugger. Any suggestions?

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Headcount!R1C1:R1048576C12", Version:=6).CreatePivotTable TableDestination _
:="Sheet11!R3C1", TableName:="PivotTable9", DefaultVersion:=6
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi and welcome to MrExel

Rich (BB code):
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Headcount!R1C1:R1048576C12", Version:=6).CreatePivotTable TableDestination _
:="Sheet11!R3C1", TableName:="PivotTable9", DefaultVersion:=6


It is a problem in the version, you must put one of the following, according to your version of excel.

NameValueDescription
xlPivotTableVersion20000Excel 2000
xlPivotTableVersion101Excel 2002
xlPivotTableVersion112Excel 2003
xlPivotTableVersion123Excel 2007
xlPivotTableVersion144Excel 2010
xlPivotTableVersion155Excel 2013


Source: XlPivotTableVersionList enumeration (Excel)
 
Upvote 0
Hi and welcome to MrExel

Rich (BB code):
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Headcount!R1C1:R1048576C12", Version:=6).CreatePivotTable TableDestination _
:="Sheet11!R3C1", TableName:="PivotTable9", DefaultVersion:=6


It is a problem in the version, you must put one of the following, according to your version of excel.

NameValueDescription
xlPivotTableVersion20000Excel 2000
xlPivotTableVersion101Excel 2002
xlPivotTableVersion112Excel 2003
xlPivotTableVersion123Excel 2007
xlPivotTableVersion144Excel 2010
xlPivotTableVersion155Excel 2013


Source: XlPivotTableVersionList enumeration (Excel)
Thank you so much for your response. I actually fixed the problem by creating a new tab, naming the tab and then when creating my pivot table indicated that the table should be created on the new tab. That solved the problem.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,054
Latest member
juliecooper255

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top