Reputation: 1
My Excel macro is written in Excel 2013, but when my colleague runs it in Excel 2010 he gets the following error:
Run-time error '5'
I'm not really an expert in VBA. Why am I getting this error?
When I run the debugger, it points me to section below:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Tempo!R1C1:R5000C5", Version:=xlPivotTableVersion15).CreatePivotTable _
TableDestination:="Tempo2!R1C1", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion15
Upvotes: 0
Views: 739
Reputation: 16321
xlPivotTableVersion15
is specific to Excel 2013.
Here are the possible values for that enumeration:
Value Version
----------------------- ----------
xlPivotTableVersion2000 Excel 2000
xlPivotTableVersion10 Excel 2002
xlPivotTableVersion11 Excel 2003
xlPivotTableVersion12 Excel 2007
xlPivotTableVersion14 Excel 2010
xlPivotTableVersion15 Excel 2013
Try changing your macro to use xlPivotTableVersion14
instead.
Upvotes: 1