It seems to be that the sheet was created in old excel, and even though it is now in new excel it still thinks it is old excel. So creating a new sheet and copy the macros and datas to that should do the trick.
type mismatch for pivot tables
-
29-08-2022 - |
Question
I can see a few others have had a similar problem, but none of the solutions that worked for them (proposed here on the site) seem to work for me.
I am using a macro to create some pivot tables. Daily, i pass it some data, and then it destroys the old pivot table and creates a new w the extra day added. It has worked fine up until today, but broke today.
When i run the below, i get a "Type 13" error saying there is a type mismatch:
Set pcPivotCache = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _ Sheets("rawdata").Range([SaveDataOffset], [SaveDataOffset].Offset([LastActiveRow] - 1, 6)), Version:=xlPivotTableVersion12)
The next line in the code is:
Set ptPivotTable = pcPivotCache.CreatePivotTable(TableDestination:=myWs.Range("B11"))
And the previous line is:
KillAllSheetPivots myWs
the variable "myWs" is a sheet that has a pivot table that starts in B11, and it seems to get cleared just fine, but then the next line breaks w that error. Even weirder, if i don't pass it today's data and just run it on the existing data (which in theory should be the same, the destruction/creation of the pivottable shouldn't know if i've added more data) works fine. Any idea what could be going wrong or how i can debug? could it be that i've exceeded a max size or something? i'm at >65000 rows now.
La solution