VBA: ActiveChart.Parent.Name ...Why?

dave2018

Board Regular
Joined
Mar 20, 2018
Messages
223
Why is the name of an active chart in the Parent of the chart?
what is the parent of a chart if it's not the worksheet??

Thanks

(this question is not a problem-solver, I just want to know the specific hierarchy...)
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Why is the name of an active chart in the Parent of the chart?
what is the parent of a chart if it's not the worksheet??

Hi Dave

That's not the name of the active chart, that's the name of the corresponding ChartObject, which is the container of the chart inside the worksheet.

A chart can is be its own chart sheet or can be embedded in a worksheet, inside a chart object.

In the first case, the chart is a separate chart sheet, the hierarchy is

Workbook->Chart sheet

In the second case, to embed a chart in a worksheet, you use a ChartObject.
The ChartObject is a container, a "box" that has a chart inside.

The hierarchy in this case is

Workbook->Worksheet->ChartObject->Chart

This ChartObject is what is seen directly by the worksheet and has its own properties like a shape, for ex.: Name, Size (Height, Width, etc.), Position (Left, Top), Outline (Line colour, etc.), etc. ...

When you use Chart.Parent.Name

you are changing the name of the ChartObject, the container of the chart.

Notice that at any time you can get a chart that is inside a worksheet out of the ChartObject into its own Chart Sheet. Just right-click on the chart, choose Move->New sheet.

In that case if you want to change its name you use directly Chart.Name

The same in the other direction, you can always embed a chart sheet inside a worksheet, for ex.: use the button on the ribbon:

Chart tools->Design->Location->Move

and select the target worksheet.

HTH
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,125
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top