Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a series to an existing chart

Status
Not open for further replies.

neunelfer

Technical User
Jul 22, 2003
5
US
Hey guyz,

I almost go crazy over here, I'm trying to automate something which creates a historysheet and add new traces to this. also automatically, the traces should be added to the chart. Everything works, but this chartthing drives me up the wall. This source code down there is one of my tries to get it fixed, but I get a "application error" when assigning the xvalues.

Does somebody know soemthing about it?

Thanx a lot guyz I appreciate your help


Worksheets(glbstrsheetname).ChartObjects(1).Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).XValues = Worksheets(glbstrsheetname).Range(Cells(3, iNewColumn), Cells(irow, iNewColumn))
ActiveChart.SeriesCollection(2).Values = Worksheets(glbstrsheetname).Range(Cells(3, iNewColumn + 1), Cells(irow, iNewColumn + 1))

 
I finally found out, where the problem is:

I've got to refer to the workshhet if I want to use the cells, like:

ActiveChart.SeriesCollection(2).XValues = Worksheets(glbstrsheetname).Range(Cells(3, iNewColumn), Worksheets(glbstrsheetname).Cells(irow, iNewColumn))
ActiveChart.SeriesCollection(2).Values = Worksheets(glbstrsheetname).Range(Worksheets(glbstrsheetname).Cells(3, iNewColumn + 1), Cells(irow, iNewColumn + 1))

 
Hi,

You should not, under normal conditions, activate and select...
Code:
Set wsGLB as WorkSheet
With wsGLB.ChartObjects(1).SeriesCollection.NewSeries
   .SeriesCollection(2).XValues = Range(wsGLB.Cells(3, iNewColumn), wsGLB.Cells(irow, iNewColumn))
   .SeriesCollection(2).Values = Range(wsGLB.Cells(3, iNewColumn + 1), wsGLB.Cells(irow, iNewColumn + 1))
End With



Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top