用于创建数据透视表的Excel宏

时间:2017-08-03 13:17:01

标签: excel excel-vba pivot vba

这是用于创建数据透视表的录制宏。 在运行它时我收到错误:

  

错误1004无法获取工作表类的数据透视表属性

    Range("_RallyQueryResultList[#All]").Select
    Sheets.Add
    ActiveWorkbook.Worksheets("Sheet30").PivotTables("PivotTable8").PivotCache. _
        CreatePivotTable TableDestination:="Sheet30!R3C1", TableName:="PivotTable9" _
        , DefaultVersion:=xlPivotTableVersion14
    Sheets("Sheet30").Select
    Cells(3, 1).Select
    With ActiveSheet.PivotTables("PivotTable9").PivotFields("Severity")
        .Orientation = xlColumnField
        .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable9").AddDataField ActiveSheet.PivotTables( _
        "PivotTable9").PivotFields("Severity"), "Count of Severity", xlCount
    With ActiveSheet.PivotTables("PivotTable9").PivotFields("Owner")
        .Orientation = xlRowField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable9").PivotFields("Requirement")
        .Orientation = xlPageField
        .Position = 1
    End With
End Sub

0 个答案:

没有答案