尝试在特定工作表上创建数据透视表 - 运行时错误' 5':无效的调用参数

时间:2018-01-22 18:44:59

标签: vba excel-vba runtime-error excel

我正在尝试创建一个宏来抓取特定工作表中的数据并在特定工作表和单元格上创建一个数据透视图但是我收到运行时错误5 - 无效的调用参数 下面是我所拥有的,第三行,它表示activeworkbook.Pivotcaches ...等等,当我点击调试时,它突出显示为excel中的错误

Sheets("Warehouse Loads").Select
Columns("A:AH").Select

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "Warehouse Loads!R1C1:R65536C34", Version:=xlPivotTableVersion10). _
    CreatePivotTable TableDestination:="Scheduled Delivery Appt - Pivot!R3C1", _
    TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
Sheets("Scheduled Delivery Appt - Pivot").Select
Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
    "PivotTable1").PivotFields("Primary Reference"), "Count of Primary Reference", _
    xlCount
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Dest City")
    .Orientation = xlColumnField
    .Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Range")
    .Orientation = xlColumnField
    .Position = 2
End With
ActiveSheet.PivotTables("PivotTable1").PivotFields("Dest City").Subtotals = _
    Array(False, False, False, False, False, False, False, False, False, False, False, False)
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Drop Appt Date")
    .Orientation = xlRowField
    .Position = 1
End With

0 个答案:

没有答案