on error goto / resume next funktioniert nicht
13.03.2007 10:32:00
Sandra
habe folgendes Problem.
Habe ein Pivot-chart erstellt und lasse per chart_calculate ein Makro automatisch ausführen, dass mir das Chart in meine gewünschte Formatierung bringt. soweit so gut.
Mein Problem ist nun, wenn ich in meiner Pivotauswahl bspw. den Monat Dezember auswähle und dort keine Werte vorhanden sind und so auch kein Chart angezeigt werden kann, dann springt das Makro in den Debugg-Modus. Ist auch in Ordnung, denn es gibt keine Datenreihen die Formatiert werden können.
Nun wollte ich erst mit [i]on error resume next [/i]die Fehlermeldung unterbinden und eine MsgBox erscheinen lassen funktioniert aber nicht. Auch mit Hilfe von [i]on error got to [/i]Fehler hatte ich keine Chance. Er springt immer wieder in den Debug-Modus.
Kann mir jemand helfen? Ach so, es ist ein Laufzeitfehler 1004
Liegt es vielleicht an Application.EnableEvents = False, dass die fehlermeldung nicht funktioniert.
Hier noch mein Code:
Private Sub Chart_Calculate()
On Error Resume Next
If Err.Number = 1004 Then
MsgBox "Keine Werte vorhanden !"
Exit Sub
End If
Application.EnableEvents = False
'Formatierung 2.Datenreihe
ActiveChart.SeriesCollection(2).DataLabels.Select
Selection.Shadow = False
Selection.Fill.TwoColorGradient Style:=msoGradientHorizontal, Variant:=4
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 2
.Fill.BackColor.SchemeColor = 50
.NumberFormat = "#,##0.00"
.Border.Weight = xlHairline
.Border.LineStyle = xlAutomatic
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 50
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = 50
.MarkerForegroundColorIndex = 50
.MarkerStyle = xlSquare
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
'Formatierung 1.Datenreihe
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.Shadow = False
Selection.Fill.TwoColorGradient Style:=msoGradientHorizontal, Variant:=4
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 2
.Fill.BackColor.SchemeColor = 41
.NumberFormat = "#,##0.00"
.Border.Weight = xlHairline
.Border.LineStyle = xlAutomatic
End With
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 5
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = 41
.MarkerForegroundColorIndex = 41
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
Application.EnableEvents = True
End Sub
Wäre super wenn jemand ein Rat oder Tipp hätte.
grüße