Flyingmeatball
Board Regular
- Joined
- Aug 15, 2007
- Messages
- 65
I've been trying to improve my understanding of the VBA I'm frequently using and I have a basic question about chartobjects. When I select a cell or a range, I can simply say write Cells(x,y).value, or range("A1").value and it will automatically select the cell on the activesheet.
When I try and select a chart however, it requires me to give:
Activesheet.chartObjects("Chart 1")
Why is this?
Also, why does it require ChartObjects("chart 1").chart.chartType?
Here's the code I wanted to shorten and what I thought I logically would shorten it to:
ActiveSheet.ChartObjects("Chart 1").Chart.ChartType = xl3DPieExploded
ChartObjects("Chart 1").ChartType = xl3DPieExploded
Can anyone explain why I need the .chart before the ChartType?
Thanks!
When I try and select a chart however, it requires me to give:
Activesheet.chartObjects("Chart 1")
Why is this?
Also, why does it require ChartObjects("chart 1").chart.chartType?
Here's the code I wanted to shorten and what I thought I logically would shorten it to:
ActiveSheet.ChartObjects("Chart 1").Chart.ChartType = xl3DPieExploded
ChartObjects("Chart 1").ChartType = xl3DPieExploded
Can anyone explain why I need the .chart before the ChartType?
Thanks!