Hello. I created a vba for my coworkers in Excel 2016. When users in 2013 run the code, they keep getting a runtime 5 error. Any suggestions? I tried various solutions on this board but can't seem to get it to work. Is it the "DefaultVersion:=6" that is creating the problem?
Code:
Cells.Find(What:="dec 17", After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"'2017 P&L'!R5C8:R250C10", Version:=6).CreatePivotTable TableDestination:= _
"'[Entity Template v013118 - 1120.xlsm]2017 P&L'!R5C12", TableName:= _
"PivotTable3", DefaultVersion:=6
ActiveWorkbook.ShowPivotTableFieldList = False
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Jan - Dec 17"), "Sum of Jan - Dec 17", xlSum
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Categories")
.Orientation = xlRowField
.Position = 1
End With