I'm trying to plot ranges to a plot which is already created on a worksheet. In the code below it is called chart1. The problem is that Xvals and Yvals are arrays of ranges. I need to plot a certain range in each array as shown. The error I get at that "NewSeries.Values = TempX " line is "RunTime error '5': Invalid procedure call or argument". tempX and tempY are defined as variant. I've also tried defining them as range. I've also tried assigning Xvals(BoxNum) directly to the .Xvalues. BoxNum is an integer corresponding to the spot in the array to plot. Any ideas what I'm doing wrong? Thanks in advance!
series.NewSeries
Set TempX = Xvals(BoxNum)
Set TempY = Yvals(BoxNum)
Set NewSeries = chart1.SeriesCollection(chart1.SeriesCollection.Count)
NewSeries.Name = "Adjusted"
NewSeries.Values = TempX
NewSeries.XValues = TempY
seriesfor example?) but it looks basically OK to me, so it's hard to say what the issue might be without seeing a more-complete set of code.