nulrichster
Is that all the code?
Have you tried breaking it down into adding the pivot cache and then creating the pivot table separately.
Set ptc = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
Utvalg)
Set pt = ptc.CreatePivotTable(TableDestination:="", TableName:="PivotTable22", DefaultVersion:=xlPivotTableVersion10)
That might not solve the problem but it might give some more insight to what's happening.
One thing I did notice when testing that code was that both TableDestination and TableName could cause errors.
The latter errored when I tried specifying the destination and there was already a pivot table in that area.
The former basically when using the same name.
Both kind of obvious I suppose.
Bookmarks