Error Creating Chart

J

jclark419

Hey guys,

I am trying to create a chart of data based on the user's selection of
data. The code is below:


Code:
--------------------

Private Sub CommandButton1_Click()
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("PFIR").range("A1:I3"), PlotBy:= _
xlRows
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = Worksheets("Data").range(Worksheets("Data").Cells(6, 2), Worksheets("Data").Cells(lastrow, 2))
ActiveChart.SeriesCollection(1).Values = Worksheets(reactorone).range(lineonerow, lineonecolumn)
ActiveChart.SeriesCollection(2).XValues = xtime
ActiveChart.SeriesCollection(2).Values = linetwo
ActiveChart.SeriesCollection(3).XValues = xtime
ActiveChart.SeriesCollection(3).Values = linethree
ActiveChart.SeriesCollection(4).XValues = xtime
ActiveChart.SeriesCollection(4).Values = linefour
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub

--------------------


The line that spits back the error is:


Code:
--------------------

ActiveChart.SeriesCollection(1).XValues = Worksheets("Data").range(Worksheets("Data").Cells(6, 2), Worksheets("Data").Cells(lastrow, 2))

--------------------


It gives me an error saying something about object or application
undefined. I don't understand why this would possibly kick back an
error, I have specifically referenced each cell and lastrow is an
integer value.

Does anyone have any ideas?

~Jason
 
?

=?iso-8859-1?q?Luis_Ram=EDrez?=

Hi:
I use something like this:

ActiveChart.SeriesCollection(1).XValues = "=Data!R" & InitialRow &
"C" & Col & ":R" & EndRow & "C" & Col

Hope this help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top