Hi All,
I have one sheet "summary" where pivot tables are created when different commandbuttons are clicked in the detail sheet. Some can view graphs from the "summary" sheet, also by clicking a command button. I want to code an error handler so when a pivot table is created and no graph is available, the program must give an error message. In other words, if pivottable2 is created and the command botton for a graph that selects pivottable1 is clicked, I need an error message. I coded the error handler (as per the coding below and the lines '''''''''''''' commented out). The functionality works, but I am sure I did not place it correctly as I run out of memory when I run the macro with the error handler in the coding.

Can someone please help me out.

'''''' dim interror as Integer

Application.ScreenUpdating = False
Sheets("GRAPH").Select
Rows("3:25").Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Sheets("SUMMARY").Select
Range("A1").Select

'''''''' on error goto errhandeler

ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel
ActiveWorkbook.Names.Add Name:="DISTRICT_GRAPH", RefersToR1C1:= _
"=OFFSET(SUMMARY!R1C2,7,0,MAX(1,COUNTA(SUMMARY !C2)-2))"
ActiveWorkbook.Names.Add Name:="DISTRICT_GRAPH_TOTAL", RefersToR1C1:= _
"=OFFSET(SUMMARY!R1C3,7,0,MAX(1,COUNTA(SUMMARY !C3)-1))"
ActiveWorkbook.Names.Add Name:="DISTRICT_GRAPH_TOTAL", RefersToR1C1:= _
"=OFFSET(SUMMARY!R1C3,7,0,MAX(1,COUNTA(SUMMARY !C3)-1))"

Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("SUMMARY").Range("DISTRICT_GRAPHISTRICT_GRAPH_TOTAL"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="GRAPH"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "SALES PER LICENSING DISTRICT"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.HasLegend = False
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.ChartTitle.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Interior.ColorIndex = xlNone
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
Selection.OnAction = "Module26.DISTRICT_GRAPH"
Selection.ShapeRange.ScaleWidth 1.45, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.ScaleHeight 1.12, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.ScaleWidth 1.25, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 1.26, msoFalse, msoScaleFromTopLeft
Range("A1").Select
''''''''' Exit Sub

'''''''' errhandler:
'''''''' interr = msgbox("Graph not available for this summary")

End Sub

Thanks again