I am generating multiple graphs. I have problems with series name. ( I am
generating only 1 series in each graph).
When the second graph is generated, the series name of the first graph changes
to the second graph's series name. When the third graph is generated, the series
name of both first & second graph changes to the third graph's series name and
so on.
Can anyone help me fix it?
Here's Code:
For rowNum = 2 To dataSheet.UsedRange.Count
If dataSheet.Cells(rowNum, 4) <> currentTestCell Or _
dataSheet.Cells(rowNum, 1) <> currentPNCell Then
endRow = rowNum - 1
'ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R9C3:R15C3"
'ActiveChart.SeriesCollection(1).Values = "=Sheet1!R9C7:R15C7"
xrangeStr = "=" & dataSheet.Name & "!R" & startRow & "C3:R" & endRow &
"C3"
valrangeStr = "=" & dataSheet.Name & "!R" & startRow & "C7:R" & endRow &
"C7"
Application.CutCopyMode = False
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = xrangeStr
ActiveChart.SeriesCollection(1).Values = valrangeStr
ActiveChart.SeriesCollection(1).Name = currentPNCell
ActiveChart.Location Where:=xlLocationAsObject, Name:=dataSheet.Name
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = currentTestCell
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Period"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Boards/hour"
End With
currentPNCell = dataSheet.Cells(rowNum, 1)
currentTestCell = dataSheet.Cells(rowNum, 4)
startRow = rowNum