View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bill Manville Bill Manville is offline
external usenet poster
 
Posts: 473
Default charting cell references

Ian Mangelsdorf wrote:
Im getting a nasty message when using this code

With ActiveChart.SeriesCollection.NewSeries
.Name = "2"
.Values = Range(.Cells(5, "b"), .Cells(5, "l"))
.XValues = Range(.Cells(length, "b"), .Cells(length, "l"))
End With


It is certainly a mistake to have . in front of Cells.

That is trying to make Cells a property of the Series object (the
object in the enclosing With statement), whereas leaving out the .
makes it a property of the ActiveSheet.

Try this

With ActiveChart.SeriesCollection.NewSeries
.Name = "2"
.Values = Range(Cells(5, "b"), Cells(5, "l"))
.XValues = Range(Cells(length, "b"), Cells(length, "l"))
End With

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup