Macro producing chart from variable length column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to produce a chart in excel from variable length column using a
macro. I find the bottom of the column and assign the row number to variable
K. I then want to assign the SeriesCollection XValues and Values but can't
seem to do it using the Cells notation as shown below. Is there another way
to approach this using the variable K for the last row in the range?

ActiveChart.SeriesCollection(1).XValues =
ActiveSheet.Range(ActiveSheet.Cells(2, 1), ActiveSheet.Cells(K, 1))

Thanks
 
Assuming that it's all on one line in your code, it looks OK to me. What error
are you getting?
 
I get Run-time error 438, Object doesn't support this property or method.
 
Is the chart embedded or on a separate sheet? If the latter, which is the
active sheet when the code runs? Is there an active chart?

Will it work correctly if you refer to the worksheet by name -- e.g.
Worksheets("Sheet1")

and refer to the chart by name?
 

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

Back
Top