I added a chart using this piece of code:
ActiveSheet.Shapes.AddChart2(419, xlFunnel).Select
Now, I wish I could select this graph, so that I can rename it.
PS: What does it mean AddChart2
? Is this standard code or not?
I added a chart using this piece of code:
ActiveSheet.Shapes.AddChart2(419, xlFunnel).Select
Now, I wish I could select this graph, so that I can rename it.
PS: What does it mean AddChart2
? Is this standard code or not?
Here you go!
Dim MyChart As Shape
Set MyChart = ActiveSheet.Shapes.AddChart2(419, xlFunnel)
MyChart.Chart.SetSourceData Source:=Range("Sheet1!$F$2:$F$4")
MyChart.Name = "My new chart"
Regarding the AddChart vs AddChart2 question - read more here What does the number in the AddChart2 VBA macro represents?