Labeling graphs using VBA

JJKNowles

Board Regular
Joined
Oct 7, 2004
Messages
92
I have a Excel Template that has 15 graphs on one page and 6 graphs on the next. Every time a technician uses the spread sheet they have to fill out all 21 graphs. To save time I wrote a macro that fills out the graph titles for them. The only problem is that each graph title has something different. So I had to ativate the graph by it's individual name. eg... "chart 1, chart 2..." and so on. Can these names change so that what was labeled chart 2 may be called chart 5 some other day? Or is this a secure method?
Thanks for your time,
JJ
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try this:

Sub Test()

Sheets(4).Activate

For a = 0 to n

ActiveSheet.ChartObjects(a).Activate
ActiveChart.ChartArea.Select

[add the code to change the name here]

next a

End Sub

This will allow you to select each graph in order.
 
Upvote 0
That's what I did. My only question is will chart 5 stay chart 5 every time we open the template. If chart 5 becomes chart 7 another time then the title assigned to it will be wronge.
 
Upvote 0

Forum statistics

Threads
1,203,545
Messages
6,056,031
Members
444,840
Latest member
RazzelDazel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top