Chart VBA problem.

S

sonicscooter

Hi, i have a button command that brings a embedded chart onto my worksheet,
it works fine, so i wanted to write a simple marco to asighn to another
button to delete the chart when i had finished looking at it, this is what
Excel recorded,

ActiveSheet.ChartObjects("Chart 5029").Activate
ActiveChart.Axes(xlValue).Select
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
Selection.Delete

Now this works as long as the "Chart 5029" number is the same as on the
chart its self ,ie when i left click and put it in a chart window to see what
the number is along the top of the box, so, i press the button, it works, i
call up a chart again with the other button, press the delete button and
error, because the Chart number as changed to one thats different to the one
in the macro. I don't know what the number is for and how to either stop it
from changing ( why does it change ) or to write a macro to adjust for the
change in this number.

Thanks to anyone who can answer this problem....Cheers
 
S

sonicscooter

Jacob, sir you are a genius, i've tried different things for a day and got
nowhere, thanks, it works really well... Cheers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top