excel - 尝试创建数据透视表时出错
问题描述
我一直在尝试运行以下宏来创建一个超出另一张数据表范围的数据透视表,但我似乎无法使其工作。
Sub topc()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Worksheets("TOP C").Delete
Sheets.Add Before:=ActiveSheet
ActiveSheet.Name = "TOP C"
Application.DisplayAlerts = True
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Complaints!R1C1:R3000C32", Version:=6).CreatePivotTable _
TableDestination:="TOP C!R1C1", TableName:="PivotTable1", _
DefaultVersion:=6
ActiveSheet.PivotTables("PivotTable1").RepeatAllLabels xlRepeatLabels
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Recurrence")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").RepeatAllLabels xlRepeatLabels
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Subtype Name")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Type Inquiry")
.Orientation = xlPageField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Value"), "Sum of Value", xlSum
End Sub
我在这个区域不断收到错误“无效的过程或参数”:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Complaints!R1C1:R3000C32", Version:=6).CreatePivotTable _
TableDestination:="TOP C!R1C1", TableName:="PivotTable1", _
DefaultVersion:=6
并不断告诉我 xlDatabase = 1, idk 如果那是问题所在。请帮忙!!
解决方案
推荐阅读
- c# - 在第二个选项卡中没有干预 Unloaded 的两个 Loaded 事件,这是一个错误吗?
- clojure - 获取错误未捕获错误:断言失败:反应是只读的;现场不允许
- regex - 如何在linux命令行中的多个文件中用计数器附加值替换重复的字符串
- java - 金字塔最小和路径 2D ArrayList IndexOutOfBounds
- c# - 解析选项卡之间的文本
- php - php得到错误条件无法正常工作
- php - 我无法上传我的网站,我的数据库失败了,我无法连接
- c# - 使用嵌套字典 C# 动态存储 xml
- javascript - Javascript 循环参考示例
- java - Kotlin 的 JvmDefault - 还需要声明方法吗?