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:=xlDatabase, 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").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Count"), "Sum of Count", xlSum
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Sheet4").Range("A3")
ActiveChart.Location Where:=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