1

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?

Jules Dupont
  • 7,259
  • 7
  • 39
  • 39
lucasnuensfe
  • 39
  • 1
  • 8
  • 1
    `AddChart2` was added in Excel 2013 to make adding charts a little easier (the older `AddChart` was retained for backwards compatibility) – Tim Williams May 02 '18 at 19:19

1 Answers1

0

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?

Sam
  • 5,424
  • 1
  • 18
  • 33