I am trying to step through a macro, created using the recorder, that builds a pivot table based on another pivot table. When I use the step-through in the VB screen to test the macro, it goes straight to debug in the first set of instructions. The error message is "Run-time error 1004" Application-defined or object-defined error.
ActiveWorkbook.Worksheets("Summary").PivotTables("SummaryPivot").PivotCache. _
CreatePivotTable TableDestination:="", TableName:="PivotTable2", _
DefaultVersion:=xlPivotTableVersion10
I've tried changing "PivotTable2" to "ControlTotals" knowing that each time I try and build the pivot table in testing it will increment by 1. No luck. 
I've searched through the archives and googled tyring to find a resolution but so far have come up empty.
Any help would be apprecitated or point me to a potential resource.
Below is the complete code to build the macro, and yes I know it needs to be cleaned up. I just need to get past this first hurdle.
Sub Macro3()
'
ActiveWorkbook.Worksheets("Summary").PivotTables("SummaryPivot").PivotCache. _
CreatePivotTable TableDestination:="", TableName:="PivotTable2", _
DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTables("PivotTable2").PivotFields("Pay Code").Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array("PSID", _
"Pay Code", "Data"), PageFields:="Batched"
With ActiveSheet.PivotTables("PivotTable2").PivotFields("BaseHours")
.Orientation = xlDataField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").PivotFields("Amount").Orientation = _
xlDataField
ActiveWorkbook.ShowPivotTableFieldList = False
ActiveSheet.PivotTables("PivotTable2").PivotFields("Batched").CurrentPage = _
"Yes"
With ActiveSheet.PivotTables("PivotTable2").PivotFields("PSID")
.PivotItems("#N/A").Visible = False
End With
ActiveSheet.PivotTables("PivotTable2").PivotSelect "", xlDataAndLabel, True
ActiveSheet.PivotTables("PivotTable2").Format xlReport4
ActiveSheet.PivotTables("PivotTable2").PivotSelect "", xlDataAndLabel, True
ActiveSheet.PivotTables("PivotTable2").Format xlPTClassic
ActiveSheet.Name = "Control Totals"
Range("A5").Select
Sheets("Control Totals").Move After:=Sheets(5)
Sheets("Control Totals").Select
End Sub
Thanks.
Bookmarks