excel - 在记录的 Pivot 宏上获取运行时错误 5
问题描述
Sub Open_Projects_pivots()
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Open_Project_Details", Version:=6).CreatePivotTable TableDestination:= _
"Open Projects pivots!R1C1", TableName:="PivotTable1", DefaultVersion:=6
Sheets("Open Projects pivots").Select
Cells(1, 1).Select
With ActiveSheet.PivotTables("PivotTable1")
.ColumnGrand = True
.HasAutoFormat = True
.DisplayErrorString = False
.DisplayNullString = True
.EnableDrilldown = True
.ErrorString = ""
.MergeLabels = False
.NullString = ""
.PageFieldOrder = 2
.PageFieldWrapCount = 0
.PreserveFormatting = True
.RowGrand = True
.SaveData = True
.PrintTitles = False
.RepeatItemsOnEachPrintedPage = True
.TotalsAnnotation = False
.CompactRowIndent = 1
.InGridDropZones = False
.DisplayFieldCaptions = True
.DisplayMemberPropertyTooltips = False
.DisplayContextTooltips = True
.ShowDrillIndicators = True
.PrintDrillIndicators = False
.AllowMultipleFilters = False
.SortUsingCustomLists = True
.FieldListSortAscending = False
.ShowValuesRow = False
.CalculatedMembersInFilters = False
.RowAxisLayout xlCompactRow
End With
With ActiveSheet.PivotTables("PivotTable1").PivotCache
.RefreshOnFileOpen = False
.MissingItemsLimit = xlMissingItemsDefault
End With
ActiveSheet.PivotTables("PivotTable1").RepeatAllLabels xlRepeatLabels
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Status")
.Orientation = xlColumnField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Labels")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("ShortId"), "Count of ShortId", xlCount
Range("A1:C4").Select
Selection.Copy
Range("A15").Select
ActiveSheet.Paste
ActiveSheet.PivotTables("PivotTable2").PivotFields("Labels").Orientation = _
xlHidden
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"Requester Team (string)")
.Orientation = xlRowField
.Position = 1
End With
End Sub
我在此代码上收到运行时错误 5,但不确定错误是什么。这是一个录制的宏。仅供参考“Open_Project_Details”是工作表中的动态表“打开项目详细信息”“打开项目枢轴”是目标工作表,将始终保留,此工作表将单击此宏的按钮
解决方案
推荐阅读
- flutter - Flutter/Dart - FutureBuilder bool 不返回 bool
- apache-spark - 读取xml时如何在spark数据框中包含元数据
- ios - 将字典中键的新值和先前值相加
- javascript - 无法获取 /ID (querystring) Express, nodeJS
- reactjs - 如何修复错误类型 void is not assignable to type ((event: MouseEvent
) => void) |未定义使用反应? - python - ModuleNotFoundError:没有名为“odata”Python 的模块
- class - 如何间接访问类的属性
- django - 有没有办法将多次相同的对象添加到多对多字段
- spotfire - 如何在spotfire中获取现有连接数据表中被忽略的列
- apache-kafka - Kafka 指标 Active Controller Count 的 Grafana 警报