Sub
chartTest()
Dim
idxRowX
As
Integer
Dim
idxColLeg
As
Integer
Dim
idxFirstCol
As
Integer
Dim
idxLastCol
As
Integer
Dim
idxRow
Dim
idxLastRow
As
Integer
Dim
ws
As
Worksheet
Dim
s
As
Series
Set
ws = ActiveWorkbook.Worksheets(
"Tabelle7"
)
Dim
ch
As
Chart
Set
ch = ws.Shapes.AddChart.Chart
ch.ChartType = xlLineMarkers
For
Each
s
In
ch.SeriesCollection
s.Delete
Next
s
idxColLeg = 1
idxRowX = rowIndex(
"x"
, idxColLeg)
idxLastRow = ws.Cells(Rows.Count, idxColLeg).
End
(xlUp).Row
For
idxRow = 1
To
idxLastRow
If
idxRow = idxRowX
Then
GoTo
nextIdxRow
If
Not
IsEmpty(ws.Cells(idxRow, idxColLeg + 1))
Then
idxFirstCol = idxColLeg + 1
Else
idxFirstCol = ws.Cells(idxRow, idxColLeg).
End
(xlToRight).Column
idxLastCol = ws.Cells(idxRow, ws.Columns.Count).
End
(xlToLeft).Column
ch.SeriesCollection.Add Source:=ws.Range(ws.Cells(idxRow, idxFirstCol), ws.Cells(idxRow, idxLastCol))
Set
s = ch.SeriesCollection(ch.SeriesCollection.Count)
s.name = ws.Cells(idxRow, idxColLeg).Value
s.XValues = ws.Range(ws.Cells(idxRowX, idxFirstCol), ws.Cells(idxRowX, idxLastCol))
nextIdxRow:
Next
idxRow
End
Sub