Makrofehler Diagramm
#1
Hallo Zusammen,

bei der Aktualisierung eines Diagramms via VBA bekomme ich plötzlich einen Fehler "Laufzeitfehler 13, Typen Unverträglichkeit". (Siehe Beispieldatei im Anhang). Das Diagramm befindet sich im Reiter "Frontend" und die Inputdaten im Reiter "Meilensteintrendanalyse". Beim Betätigen des Buttons "Meilensteintrendanalyse" sollte das ganze eigentlich klappen.
Die 4. Zeile von unten wird beim Debuggen angezeigt. Also die hier:

ActiveChart.Axes(xlCategory).MinimumScale = .Cells(7, ErstebefüllteZelle - 1).Value

Das wäre der Code:

Code:
Sub DiagrammMeilenstein()
Dim LetzteZeile As Long, d As Integer
Dim loLetzte As Long, raFund As Range, raFund1 As Range, ErstebefüllteZelle As Long, LetztebefüllteZelle As Long
Dim i As Long, z As Long, j1 As Long, j2 As Long

'Startzeile Ergebnis
z = 2

'Blattname anpassen
With Worksheets("Meilensteintrendanalyse")
Call Blattschutz_aus
   loLetzte = .Cells(.Rows.Count, 1).End(xlUp).Row
   For i = 6 To 6
       Set raFund = .Rows(i).Find(what:=1, after:=.Cells(i, 1), LookIn:=xlValues, lookat:=xlWhole, _
       searchorder:=xlByColumns, searchdirection:=xlNext)
       Set raFund1 = .Rows(i).Find(what:=1, LookIn:=xlValues, lookat:=xlWhole, _
       searchorder:=xlByColumns, searchdirection:=xlPrevious)
       If Not raFund Is Nothing Then
         
           ErstebefüllteZelle = raFund.Column
           LetztebefüllteZelle = raFund1.Column
           z = z + 1
       End If
   Next i

       
Set raFund = Nothing: Set raFund1 = Nothing
LetzteZeile = .Cells(Rows.Count, 3).End(xlUp).Row
Range("G4:BB4").Select
   Selection.ClearContents

For j1 = ErstebefüllteZelle To LetztebefüllteZelle
For j2 = 9 To LetzteZeile
If Month(.Cells(j2, ErstebefüllteZelle)) = Month(.Cells(7, j1)) And year(.Cells(j2, ErstebefüllteZelle)) = year(.Cells(7, j1)) Then
.Cells(4, j1) = .Cells(j2, ErstebefüllteZelle)

End If
Next j2
Next j1


   
    Sheets("Frontend").ChartObjects("Diagramm Meilensteintrendanalyse").Activate
ActiveChart.SeriesCollection.NewSeries
     ActiveChart.FullSeriesCollection(1).name = "Planlinie"
     ActiveChart.FullSeriesCollection(1).XValues = .Range(.Cells(7, ErstebefüllteZelle), .Cells(7, LetztebefüllteZelle))
     ActiveChart.FullSeriesCollection(1).Values = .Range(.Cells(4, ErstebefüllteZelle), .Cells(4, LetztebefüllteZelle))
     ActiveChart.FullSeriesCollection(1).ApplyDataLabels
     ActiveChart.FullSeriesCollection(1).DataLabels.Delete
     
   Sheets("Frontend").ChartObjects("Diagramm Meilensteintrendanalyse").Activate
   For i = 9 To LetzteZeile
     ActiveChart.SeriesCollection.NewSeries
     ActiveChart.FullSeriesCollection(i - 7).name = .Cells(i, 6).Value
     ActiveChart.FullSeriesCollection(i - 7).XValues = .Range(.Cells(7, ErstebefüllteZelle), .Cells(7, LetztebefüllteZelle))
     ActiveChart.FullSeriesCollection(i - 7).Values = .Range(.Cells(i, ErstebefüllteZelle), .Cells(i, LetztebefüllteZelle))
     ActiveChart.FullSeriesCollection(i - 7).Points(1).Select
     ActiveChart.FullSeriesCollection(i - 7).Points(1).ApplyDataLabels
     ActiveChart.FullSeriesCollection(i - 7).Points(1).DataLabel.Select
     Selection.ShowSeriesName = -1
     Selection.ShowValue = 0
     Selection.Left = 233.218
     
        ActiveChart.FullSeriesCollection(i - 7).DataLabels.Select
   ActiveChart.FullSeriesCollection(i - 7).Points(1).DataLabel.Select
   Selection.Format.TextFrame2.TextRange.Font.Size = 28
   Selection.Format.TextFrame2.TextRange.Font.Bold = msoFalse
   Selection.Format.TextFrame2.TextRange.Font.Bold = msoTrue
 
 
   With ActiveChart.FullSeriesCollection(i - 7).Format.Line
       .Visible = msoTrue
       .Weight = 6
   End With
   Next i
   ActiveChart.Axes(xlValue).MinimumScale = .Cells(7, ErstebefüllteZelle).Value
   ActiveChart.Axes(xlValue).MajorUnit = 92

   
   ActiveChart.Axes(xlCategory).MinimumScale = .Cells(7, ErstebefüllteZelle - 1).Value
Call Blattschutz_ein
End With
End Sub


Angehängte Dateien
.xlsm   Meilenstein2.xlsm (Größe: 373,21 KB / Downloads: 4)
Top
#2
Hallo

Ich bekomme beim öffnen deiner Datei direkt mehrere Fehler. Kann nicht geöffnet werden!

Lg
Marcus

Wissen ist Macht - es ist aber nicht schlimm nicht alles zu wissen.
Man muss nicht alles wissen - man muss nur wissen wo es steht, oder wo man Hilfe bekommt.
Top


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 2 Gast/Gäste