rjplante
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 574
- Office Version
- 365
- Platform
- Windows
I have a macro that inserts a chart and I would like to rename the chart from Chart 1, 2, 3, etc. to Graph 1 so that I can refer to the chart by name and move it to another sheet, format it, etc. How do I rename this element? Each time I run my macro it ups the chart name from 2 to 3, etc. How can I reference the current chart name when I don;t know how to refer to it in VBA code?
Thanks,
Robert
Thanks,
Robert
Code:
Range("DL2").Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLineMarkers
ActiveSheet.ChartObjects("Chart 1").Name = "Graph 1"
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.SetElement (msoElementPrimaryValueGridLinesNone)
ActiveChart.SetElement (msoElementLegendNone)
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
ActiveSheet.ChartObjects("Graph 1").Activate
ActiveChart.Location Where:=xlLocationAsObject, Name:="Graph Display"
Last edited: