在创建数据透视表时,我无法克服这一错误。它一直说
上有一个“无效的过程调用或参数”Sub AlternateRowColors()
Dim lastAddress As String
Dim myRange As Range, xlApp As Object, xlBook As Object, xlSheet As Object, xlObj As Object, xlPC As Object, xlPT As Object, xlPI As Object
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("L:\WF Reporting\Superdash\Superdash_Reporting.xlsx")
Set xlSheet = xlBook.Sheets(4)
xlApp.Visible = True
For Each Sheet In xlBook.Sheets
lastAddress = Sheet.Range("A1").SpecialCells(xlCellTypeLastCell).Address
Sheet.Activate
Set xlLo = Sheet.ListObjects.Add(xlSrcRange, Range("A1:" & lastAddress), , xlYes)
xlLo.TableStyle = "TableStyleMedium16"
Next Sheet
Set xlPC = xlBook.PivotCaches.Create(xlDatabase, "tbl_Superdash_Bot_Rpt", xlPivotTableVersion15)
Set xlObj = xlBook.Sheets.Add(xlSheet)
Set xlPT = xlPC.CreatePivotTable(xlLo.Range("A3"), "Superdash_Bot_pivot")
xlObj.Name = "Summary"
With xlPT
.RowAxisLayout xlTabularRow
.InGridDropZones = True
.DisplayErrorString = True
.ShowTableStyleRowStripes = True
With .PivotFields("Bot_Skill_Name")
.Orientation = xlPageField
End With
With .PivotFields("Human_Skill_Name")
.Orientation = xlPageField
End With
End With
xlBook.Save
xlBook.Close
xlApp.Quit
End Sub
我在
上遇到错误Set xlPT = xlPC.CreatePivotTable(xlLo.Range("A3"), "Superdash_Bot_pivot")'
行。就是说有一个
无效的通话或参数
。在我看来,所有这些都是先前定义的。我想念什么?