In Microsoft Office Excel 2007, you have a recorded macro that performs the following operations:
- Create a new PivotTable from the data table in a worksheet.
- Put the new PivotTable into a new worksheet.
When you play the recorded macro, you receive one of the following error messages:
- Error message 1
Run-time error '1004': Application-defined error.
- Error message 2
Run-time error '5':
Invalid procedure call or argument.
Note The following code is an example of a recorded macro.
Sub Macro1()
'
' Macro1 Macro
'
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R12C2", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Sheet4!R3C1", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Sheet4").Select
Cells(3, 1).Select
End Sub