Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi I've recorded a macro that creates a pivot table from a large sum of data and then creates a chart. However everytime the button that enables the macro is pushed i get a run time error (although the table and chart are created perfectly well!) the code is Sub Pivot01() ' ' Pivot01 Macro ' Macro recorded 26/09/2005 by bbnr843 ' ' Range("C8").Select Application.CutCopyMode = False ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _ "Sheet1!R8C3:R2145C21").CreatePivotTable TableDestination:="", TableName:= _ "PivotTable1", DefaultVersion:=xlPivotTableVersion10 ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1) ActiveSheet.Cells(3, 1).Select With ActiveSheet.PivotTables("PivotTable1").PivotFields ("YearMonth") ..Orientation = xlRowField ..Position = 1 End With With ActiveSheet.PivotTables("PivotTable1").PivotFields ("WPBH_BH_PRTYSTATUS") ..Orientation = xlColumnField ..Position = 1 End With ActiveSheet.PivotTables("PivotTable1").AddDataFiel d ActiveSheet.PivotTables( _ "PivotTable1").PivotFields("Count"), "Sum of Count", xlSum Charts.Add ActiveChart.SetSourceData Source:=Sheets("Sheet4").Range("A3") ActiveChart.Location Whe=xlLocationAsNewSheet ActiveChart.PlotArea.Select ActiveChart.HasDataTable = True ActiveChart.DataTable.ShowLegendKey = True End Sub The red line is the one that gets flagged by the debug. I think its to do with the range A3 but i'm not sure what to or how to change it! Any help with this would be great. Kind Regards Matt -- matthewwookie ------------------------------------------------------------------------ matthewwookie's Profile: http://www.excelforum.com/member.php...o&userid=27503 View this thread: http://www.excelforum.com/showthread...hreadid=470684 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem inserting calculated pivot fields into Pivot Table (2007) | Excel Discussion (Misc queries) | |||
CHANGE MARCO PROBLEM | Excel Discussion (Misc queries) | |||
Pivot Table in Excel 2007 : Problem with % in Table | Excel Discussion (Misc queries) | |||
marco after selection in PV table | Excel Programming | |||
Marco: Pivot Table | Excel Programming |