Naming Charts

Dear Experts:

below code snippet is supposed to name Charts in the following syntax:


The 'format'-part of the code is obviously not correct. How do I have change the code so that the charts are correctly named?

With myChtObj.Chart.Parent  
           .Name = Format("MyChart_" & i + 1, "_##")
End With
        i = i + 1

Help is much appreciated. Thank you very much in advance.

Regards,  Andreas
Andreas HermleTeam leaderAsked:
Who is Participating?
Rory ArchibaldCommented:
Would it not be:
 .Name = "MyChart_" & Format( i + 1, "00")
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:


           .Name = "MyChart_" & Format( i + 1, "_##")

I assume the i is part of a for/next loop? why do you then add a 1 to i? This would be a bit easier with more of your code. Can you post the whole for/next loop?

cheers, teylyn
Andreas HermleTeam leaderAuthor Commented:
Hi teylyn,

thank you very much for your swift support. I am off to lunch and will get back to you afterwards.

Regards, Andreas
Rory ArchibaldCommented:
And just:
With myChtObj

Rather than:
With myChtObj.Chart.Parent  
Andreas HermleTeam leaderAuthor Commented:
Hi Brad:

ok, great, this works just fine. Thank you very much for your professional help.
Teylyn, I am awarding 50 points to you since the syntax of the code snippet is correct. Thank you very much.

Regards, Andreas
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.