Excel/PIvot table macro recording problem
I 've been recording a macro for pivot table and chart, but my code only runs to creating the pivot table(without inputting data). I'm wondering if it's the code problem or I need to add additional add-ins? Here below is my code, could you please help?
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R4C1:R15C3").CreatePivotTable TableDestination:="[Book3]Sheet2!R12C5" _
, TableName:="PivotTable", DefaultVersion:=xlPivotTableVersion10
.Orientation = xlRowField
.Position = 1
ActiveSheet.PivotTables("PivotTable").AddDataField ActiveSheet.PivotTables( _
"PivotTable").PivotFields("sum of Y"), "Sum of sum of Y", xlSum
Thanks a lot
Recording macros is always a good starting point, but as you've discovered, not always the end of the process - however, I'm not 100% clear what it was you wanted the macro to do - my GUESS would be that it would need to update the data range and refresh the data - which can be done with an existing chart, without the need to create it first - can you clarify what you wanted the macro to do?
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here