Hallo zusammen,
ich habe ein Makro, dass mir aus einer Tabelle automatisch ein Diagramm erzeugt. Ein weiteres Makro, soll nun dieses Diagramm formatieren (Farben, Diagrammtyp etc.). Jetzt habe ich allerdings das Problem, dass neu angelegte Diagramme fortlaufend nummeriert werden. Ich weiß jedoch nicht, wie ich dies in meinem zweiten Makro berücksichtigen kann, so dass es egal ist, welchen Namen das erzeugte Diagramm hat.
Hier mein Makro-Code, der nicht funktioniert, weil er sich auf einen festen Diagramm-Namen bezieht:
ActiveSheet.Shapes(„Chart 29“).Select
Selection.Name = „Nutzgraddiagramm“
Range(„H27“).Select
ActiveSheet.ChartObjects(„Nutzgraddiagramm“).Activate
ActiveChart.SeriesCollection(2).Select
ActiveChart.SeriesCollection(2).ChartType = xlLine
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 4
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
With Selection.Border
.ColorIndex = 10
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 37
.Pattern = xlSolid
End With
ActiveChart.SeriesCollection(1).Points(1).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 41
.Pattern = xlSolid
End With
ActiveChart.ChartArea.Select
ActiveSheet.Shapes(„Nutzgraddiagramm“).IncrementLeft -48.75
ActiveSheet.Shapes(„Nutzgraddiagramm“).IncrementTop -6#
ActiveSheet.Shapes(„Nutzgraddiagramm“).ScaleWidth 1.58, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes(„Nutzgraddiagramm“).ScaleHeight 1.29, msoFalse, _
msoScaleFromTopLeft
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 3
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
ActiveWindow.Visible = False
Windows("# Pareto + GAE-Potential # test.xls").Activate
Range(„A1:M1“).Select
End Sub
Schon mal Danke im Voraus,
ck