ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to set a variable to a Chart? not ChartObject (https://www.excelbanter.com/excel-programming/331065-how-set-variable-chart-not-chartobject.html)

Rich

how to set a variable to a Chart? not ChartObject
 
Sheet1 contains "Chart 1"

I want to set a variable to "Chart 1"

Dim chrt As Chart
Set chrt = Sheets("Sheet1").ChartObjects("Chart 1")

This gives a type mismatch error. If I Dim chrt As ChartObject then I do
not get the chart methods/properties in the dropdown. But I don't see any
other options for setting chrt to "Chart 1". Any suggestions appreciated.

Thanks,
Rich

Tom Ogilvy

how to set a variable to a Chart? not ChartObject
 
Dim chrt As Chart
Set chrt = Sheets("Sheet1").ChartObjects("Chart 1").Chart

--
Regards,
Tom Ogilvy


"Rich" wrote in message
...
Sheet1 contains "Chart 1"

I want to set a variable to "Chart 1"

Dim chrt As Chart
Set chrt = Sheets("Sheet1").ChartObjects("Chart 1")

This gives a type mismatch error. If I Dim chrt As ChartObject then I do
not get the chart methods/properties in the dropdown. But I don't see any
other options for setting chrt to "Chart 1". Any suggestions appreciated.

Thanks,
Rich




Rob Bovey

how to set a variable to a Chart? not ChartObject
 
"Rich" wrote in message
...
I want to set a variable to "Chart 1"

Dim chrt As Chart
Set chrt = Sheets("Sheet1").ChartObjects("Chart 1")

This gives a type mismatch error. If I Dim chrt As ChartObject then I do
not get the chart methods/properties in the dropdown. But I don't see any
other options for setting chrt to "Chart 1". Any suggestions appreciated.


Hi Rich,

This is how to get at the underlying Chart contained in a ChartObject:

Set chrt = Sheets("Sheet1").ChartObjects("Chart 1").Chart

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm



Rich

how to set a variable to a Chart? not ChartObject
 
Thanks all for your replies. Really appreciate it.

Rich


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

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