I have recorded a macro using Excel 2007 macro recorder. This macro selects a certain range, and then creates and places a Pivot Table on a different sheet. I figured using record it would work, but with out any changes to the macro, I get a Runtime Error 5 (Invalid Procedure or Argument). I shouldn't get this error, since it is a recorded macro, but I need help figuring out what is wrong. Here is the macro:
Sub Macro15() ' ' Macro15 Macro ' ' Sheets("B3 Production Input").Select Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select ' *** Below is where it errors out *** ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _ "B3 Production Input!R1C1:R111C7", Version:=xlPivotTableVersion12). _ CreatePivotTable TableDestination:="B3 Yield Report!R3C1", TableName:= _ "PivotTable8", DefaultVersion:=xlPivotTableVersion12 '*** End of Error *** Sheets("B3 Yield Report").Select Cells(3, 1).Select ActiveSheet.PivotTables("PivotTable8").Name = "B3 Yield Input" ActiveSheet.PivotTables("B3 Yield Input").AddDataField ActiveSheet.PivotTables( _ "B3 Yield Input").PivotFields("Run #"), "Sum of Run #", xlSum ActiveSheet.PivotTables("B3 Yield Input").AddDataField ActiveSheet.PivotTables( _ "B3 Yield Input").PivotFields("Total BF"), "Sum of Total BF", xlSum With ActiveSheet.PivotTables("B3 Yield Input").PivotFields("Sum of Run #") .Orientation = xlRowField .Position = 1 End With With ActiveSheet.PivotTables("B3 Yield Input").PivotFields("Sum of Total BF") .Caption = "Total Input BdFt" .NumberFormat = "#,##0.000" End With ActiveSheet.PivotTables("B3 Yield Input").CompactLayoutRowHeader = "Run #" Range("D3").Select End Sub Please assist. --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---