我根据 Microsoft 教程页面上的示例 VBA 代码创建了一个子例程:LINK
Sub WIP20Pivot()
'
' Pivot Macro
'Creates a PivotTable report from the table on Sheet1
'by using the PivotTableWizard method with the PivotFields
'method to specify the fields in the PivotTable.
Dim objTable As PivotTable, objField As PivotField
' Select the sheet and first cell of the table that contains the data.
ActiveWorkbook.Sheets("DATA").Select
Range("A1").Select
' Create the PivotTable object based on the Employee data on Sheet1.
Set objTable = Sheet1.PivotTableWizard 'ERROR OCCURS HERE
ActiveSheet.Name = "PivotSheet"
'There is more VBA code below to select fields for the pivot table, etc..
End Sub
当我运行此代码时,我收到以下错误:
运行时错误“424”:“需要对象”。
奇怪的是,该子程序在微软教程页面上的可下载示例宏中运行良好。
提前感谢您的帮助!
谢谢, AME