Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
852to856
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
852to856
852to856
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

on error goto / resume next funktioniert nicht

on error goto / resume next funktioniert nicht
13.03.2007 10:32:00
Sandra
Hallo zusammen,
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

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: on error goto / resume next funktioniert nicht
13.03.2007 10:37:29
Andi
Hi,
so müsste es gehen:
Private Sub Chart_Calculate()
On Error GoTo errorhandler
Application.EnableEvents = False
'

Schönen Gruß,
Andi
AW: on error goto / resume next funktioniert nicht
13.03.2007 10:44:00
Sandra
Danke Andi für deine Mühe, aber leider funktioniert es immer noch nicht.
AW: on error goto / resume next funktioniert nicht
13.03.2007 15:17:00
Andi
Hi,
sorry, da fällt mir im Augenblick leider nix ein...
Schönen Gruß,
Andi
AW: on error goto / resume next funktioniert nicht
13.03.2007 21:10:28
Harry
Hallo Sandra,
vielleicht so?
Private Sub Chart_Calculate()

On Error GoTo errorhandler

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

Exit Sub

errorhandler:

If Err.Number = 1004 Then
MsgBox "Keine Werte vorhanden !"
End If
End Sub

Gruß
Harry
Anzeige

280 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige