View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default Name a Chart so that I can adjust it's position on the worksheet(programmatically)

When you make a new chart it is initially created on its own chartsheet
and then inserted as an object onto the required sheet. When this
happens the name gets changed which is why you are struggling to
reference it.

One way around this is to use the index of the charts on the sheet. The
most recently added chart will have the highest index number so
something like this should work if the only shapes you have on the sheet
are charts:

ActiveSheet.Shapes(ActiveSheet.ChartObjects.Count) . _
IncrementLeft 126#
ActiveSheet.Shapes(ActiveSheet.ChartObjects.Count) . _
IncrementTop -72.75

Hope this helps
Rowan

RPIJG wrote:
I tried using the Macro recorder to do this, and then assigning the
macro code to a command button on the worksheet it didn't work out so
well, I need to name the chart so that I can tell the code what chart
to move because apparently it won't accept the name it generates in the
macro code.