ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error Creating Chart (https://www.excelbanter.com/excel-programming/366330-error-creating-chart.html)

jclark419[_7_]

Error Creating Chart
 

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 Whe=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


--
jclark419
------------------------------------------------------------------------
jclark419's Profile: http://www.excelforum.com/member.php...o&userid=25430
View this thread: http://www.excelforum.com/showthread...hreadid=558543


Luis Ramírez

Error Creating Chart
 
Hi:
I use something like this:

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

Hope this help



All times are GMT +1. The time now is 05:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com