Chart Naming

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
574
Office Version
  1. 365
Platform
  1. 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

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:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,224,618
Messages
6,179,919
Members
452,949
Latest member
beartooth91

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