Naming Charts

Dear Experts:

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

MyChart_01
MyChart_02
MyChart_03
etc.

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")
0
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

try

           .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
0
 
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
0
 
Rory ArchibaldCommented:
And just:
With myChtObj

Rather than:
With myChtObj.Chart.Parent  
0
 
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
0
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.