Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Naming series in multiple Graphs

  Asked By: Carlton    Date: Nov 29    Category: MS Office    Views: 722
  

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

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Andrew Brown     Answered On: Nov 29

Your code  seems to generate a number of "graphs" in one place. i.e. they are
all piled on top of each other. They are strange graphs  as they have only one
point plotted (plus a value of 1 for series  2). All the graphs seem to be
different.

It might help  if you could tell us what your data looks like and what you are
trying to do. Also could you post the code for the whole sub so we can
understand it.

The series name for Series 1 in each graph  seems to be the value of column A
in the relevant row. The Graph Title is Column D for the row.

I cannot reproduce your problem but it may relate to other parts of the code
which you have not yet told us.

 
Didn't find what you were looking for? Find more on Naming series in multiple Graphs Or get search suggestion and latest updates.




Tagged: