Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Chart VBA problem.

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Chart VBA problem.

If you have only one chart use

ActiveSheet.ChartObjects(1).Activate
--
If this post helps click Yes
---------------
Jacob Skaria


"sonicscooter" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Chart VBA problem.

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

"sonicscooter" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Chart VBA problem.

If you have multiple charts and this is the last one added, use:

ActiveSheet.ChartObjects(ActiveSheet.ChartObjects. Count).Activate

- Jon
-------
Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
Advanced Excel Conference - Training in Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html
_______


"Jacob Skaria" wrote in message
...
If you have only one chart use

ActiveSheet.ChartObjects(1).Activate
--
If this post helps click Yes
---------------
Jacob Skaria


"sonicscooter" wrote:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pie Chart problem SURGEON1971 Excel Discussion (Misc queries) 0 April 8th 09 09:57 AM
Name & chart problem Victor Delta[_2_] Excel Discussion (Misc queries) 2 January 27th 09 05:56 PM
Pie Chart Problem sfar007 Charts and Charting in Excel 0 July 19th 06 03:18 PM
Chart problem. boh Excel Programming 3 October 18th 05 03:34 PM
chart problem mayuss[_4_] Excel Programming 0 August 16th 04 02:03 PM


All times are GMT +1. The time now is 02:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"