View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JW[_2_] JW[_2_] is offline
external usenet poster
 
Posts: 638
Default How come code written by a macro won't replay in excel 2008?

On May 22, 9:46*am, wrote:
Hi all,

I recorded a macro and selected a chart sheet and the chart on it and
it wrote the code:

ActiveSheet.ChartObjects("Chart 1").Activate

I then rerean the code and was kind of surpirsed when the code came up
with the message that
the item was not found. There seems to be a difference between the
code when it is recorded from a macro and when it is written which
seems wrong to me, if the object oroducres the code in the macro when
selected why on earth will it not select when it is run back, I am
somewhat nonplussed! I was pretty proficient at programming excel 2003
but the latest version seems to be a lot less user friendly am I
right?

Thanks and regards, Mark


Your code is using ActiveSheet because of how it was recorded. If you
are trying to run just this piece of code while you are on a different
sheet, you would receive an error that the object wasn't found if you
do not have a chart on that sheet called Chart 1. Try changing it to:
Sheets("ChartSheetName").ChartObjects("Chart 1").Activate

If you are infact trying to run this from the sheet that contains
Chart 1 and it is still telling you that the object isn't found, that
is very odd unless the name of the chart changed somehow.