ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro producing chart from variable length column (https://www.excelbanter.com/excel-programming/314984-macro-producing-chart-variable-length-column.html)

JohnK

Macro producing chart from variable length column
 
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

Myrna Larson

Macro producing chart from variable length column
 
Assuming that it's all on one line in your code, it looks OK to me. What error
are you getting?

On Wed, 27 Oct 2004 19:15:03 -0700, "johnk"
wrote:

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



johnrkeir

Macro producing chart from variable length column
 
I get Run-time error 438, Object doesn't support this property or method.

"Myrna Larson" wrote:

Assuming that it's all on one line in your code, it looks OK to me. What error
are you getting?

On Wed, 27 Oct 2004 19:15:03 -0700, "johnk"
wrote:

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




Myrna Larson

Macro producing chart from variable length column
 
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?


On Wed, 27 Oct 2004 19:49:05 -0700, johnrkeir
wrote:

I get Run-time error 438, Object doesn't support this property or method.

"Myrna Larson" wrote:

Assuming that it's all on one line in your code, it looks OK to me. What

error
are you getting?

On Wed, 27 Oct 2004 19:15:03 -0700, "johnk"


wrote:

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





johnrkeir

Macro producing chart from variable length column
 
Thanks, I used Sheets("Sheet1") ... and it worked.

"Myrna Larson" wrote:

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?


On Wed, 27 Oct 2004 19:49:05 -0700, johnrkeir
wrote:

I get Run-time error 438, Object doesn't support this property or method.

"Myrna Larson" wrote:

Assuming that it's all on one line in your code, it looks OK to me. What

error
are you getting?

On Wed, 27 Oct 2004 19:15:03 -0700, "johnk"


wrote:

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






All times are GMT +1. The time now is 07:23 PM.

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