0

I am trying add a new chart1 sheet and adding series from sheet1 to my chart1 sheet.

Here is my code...

Charts.Add
With ActiveChart
    .ChartType = xlLine
    .HasTitle = True
    .ChartTitle.Text = "Closing Price"
    .SeriesCollection.NewSeries
    .FullSeriesCollection.XValues = "=Sheet1!$A$2:$A$741" '<<<<This is the xvalue
    .FullSeriesCollection.Values = "=Sheet1!$B$2:$B$741"  '<<<<This are the value 
End With

Please tell me how to do this.. Thanks in Advance

Community
  • 1
  • 1
Sanjeev Shinde
  • 63
  • 1
  • 3
  • 14

1 Answers1

0

You have to specify the number of the series collection.

Charts.Add
With ActiveChart
    .ChartType = xlLine
    .HasTitle = True
    .ChartTitle.Text = "Closing Price"
    .SeriesCollection.NewSeries
    .FullSeriesCollection(1).XValues = "=Sheet1!$A$2:$A$741" '<<<<This is the xvalue
    .FullSeriesCollection(1).Values = "=Sheet1!$B$2:$B$741"  '<<<<This are the value
End With

By the way, if you took the trouble to fire up the macro recorder, insert a new chart sheet, define new series, then stop the macro recorder, you would see all the commands laid out in full.

teylyn
  • 34,374
  • 4
  • 53
  • 73