How to Define names of Charts in a worksheet using vba

  • I have a spreadsheet and am copying the spreadsheet and updating the 7 charts on the sheet with data on this new sheet. No problems here and has been working for some six months. came back today after my christmas break and the charts are now causing errors. Code is below.


    My question is where does excel assign the chart name, as I think it has corrupted as the data is being assigned to the wrong chart. any help would be gratefully appreciated.


    The error i get is: Method 'Seriescollection' of object '_chart' failed

  • Re: How to Define names of Charts in a worksheet using vba


    Hi Giorgio,


    You can check and alter then chartobjects name by holding the CTRL key when selecting the chart. This will display the charts name in the name box, next to the formula bar. You can also change it there.


    To rename the selected chart using VBA try


    Code
    activechart.parent.name = "MyChart"

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!