I have this macro with the lines below (this is also the highlighted part when error is encountered) that previously works on win7 - ms office '10 and '13. But in win10 office 365, it errors out with the message invalid procedure call - runtime error 5. I've found some online like changing the pivot version but none work so far.
VBA Code:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R17C26", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="Sheet2!R1C1", TableName:="PivotTable4", DefaultVersion _
:=xlPivotTableVersion14