Sub
Create_MSTA_KW()
Dim
rngBereich
As
Range
Dim
lngLetzte
As
Long
Dim
lngReihe
As
Long
Dim
cht
As
Chart
With
Worksheets(
"P3_MSTA_Daten_KW"
)
lngLetzte = IIf(IsEmpty(.Cells(.Rows.Count, 2)), _
.Cells(.Rows.Count, 2).
End
(xlUp).Row, .Rows.Count)
Set
rngBereich = .Range(.Cells(14, 2), .Cells(lngLetzte, 55))
End
With
With
Worksheets(
"P3_MSTA_Diagramm_KW"
)
If
.ChartObjects.Count > 0
Then
Set
cht = .ChartObjects(
"MSTA_KW"
).Chart
Else
Set
cht = .Shapes.AddChart.Chart
End
If
With
cht
.ChartType = xlLineMarkers
.SetSourceData Source:=rngBereich, PlotBy:=xlRows
.Parent.Name =
"MSTA_KW"
.Legend.IncludeInLayout =
True
.SetElement (msoElementPrimaryValueGridLinesNone)
.SeriesCollection(1).XValues = Worksheets(
"P3_MSTA_Daten_KW"
).Range(
"C14:BC14"
)
With
.Axes(xlValue)
.MaximumScale = 52
.MinimumScale = 0
.MajorUnit = 1
.TickLabels.NumberFormat =
"KW ##"
.TickLabels.NumberFormat =
"KW ##"
End
With
With
.Axes(xlCategory)
.TickLabels.NumberFormat =
"KW ##"
.TickLabels.NumberFormat =
"KW ##"
.AxisBetweenCategories =
False
End
With
For
lngReihe = 1
To
.SeriesCollection.Count
With
.SeriesCollection(lngReihe)
.MarkerStyle = 2
.MarkerSize = 8
End
With
Next
lngReihe
With
.Parent
.Top = .Parent.Range(
"B5"
).Top
.Left = .Parent.Range(
"B5"
).Left
.Width = 1200
.Height = 800
End
With
End
With
End
With
Set
rngBereich =
Nothing
Set
cht =
Nothing
End
Sub