创建数据透视表时类型不匹配:Excel vba [英] Type mismatch during creation of pivot table : Excel vba
本文介绍了创建数据透视表时类型不匹配:Excel vba的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ActiveWorkbook.PivotCaches.Create(SourceType:= xlDatabase,SourceData:= rngData,_
版本:= xlPivotTableVersion12) .CreatePivotTable TableDestination:= wsPvtTbl.Range(A1),_
TableName:=PivotTable1,DefaultVersion:= xlPivotTableVersion12
请帮助我。
提前感谢
解决方案
你可以用你的rngData变量使用这样的东西:
ActiveWorkbook.PivotCaches.Create(SourceType:= xlDatabase,SourceData:='& rngData.Worksheet.name&'!& rngData .Address(参考:= xlR1C1),_
版本:= xlPivotTableVersion12).CreatePivotTable TableDestination:= wsPvtTbl.Range(A1),_
TableName:=PivotTable1,DefaultVersion:= xlPivotTableVersion12
I new to VBA. I am trying to create pivot table for very big record(around 30K Record). This is my code for creating the pivot table. while creating the pivot table it throws error as "Type mismatch". It was working fine for small set of records.
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=rngData, _
Version:=xlPivotTableVersion12).CreatePivotTable TableDestination:=wsPvtTbl.Range("A1"), _
TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion12
Please help me on this. Thanks in advance
解决方案
You can use something like this with your rngData variable:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="'" & rngData.Worksheet.name & "'!" & rngData.Address(referencestyle:=xlR1C1), _
Version:=xlPivotTableVersion12).CreatePivotTable TableDestination:=wsPvtTbl.Range("A1"), _
TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion12
这篇关于创建数据透视表时类型不匹配:Excel vba的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文