繁体   English   中英

VBA:创建数据透视表时出错

[英]VBA : error in creating pivot table

我正在尝试使用以下代码在VBA(Excel 2013)中创建数据透视表

Dim pt As PivotTable
Dim cache As PivotCache

Sheets("data").Select
Set cache=ActiveWorkbook.PivotCaches.Create(xlDatabase,Cells(1,1).CurrentRegion)

Sheets("pivot").Select
Set pt = cache.CreatePivotTable("R4C")

我在行设置pt中遇到错误。 请帮助确定错误。

您是正确的“ RC”字符串有效...但您需要完整的参考!

要使其正常工作,请使用以下命令:

Dim pt As PivotTable
Dim cache As PivotCache

Set cache = ActiveWorkbook.PivotCaches.Create(xlDatabase, Sheets("data").Cells(1, 1).CurrentRegion)

Set pt = cache.CreatePivotTable("'pivot'!R4C")

请检查目标处是否还有另一个对象(可能导致错误)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM