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