Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
PaulW
 
Posts: n/a
Default Assign charts names in VBA?

Two charts, one on "Options" page, one on "Data" page. Make a simple macro
that switches the two round.
Recorded a macro, and when I tried to run it I got an error.


ActiveSheet.ChartObjects("Chart 51").Activate
ActiveChart.ChartArea.Select
ActiveChart.Location Whe=xlLocationAsObject, Name:="Data"

Then Chart 24 to "Options". Also recorded the bit where they switch back.
But Chart 24 is now Chart 25, and Chart 51 is now Chart 54. The numbers seem
to go up each time something is done with a chart... As such, when I try and
run the macro again the charts have different numbers and it fails.

Can you assign a name to a chart to provent this?

  #3   Report Post  
Posted to microsoft.public.excel.misc
PaulW
 
Posts: n/a
Default Assign charts names in VBA?



"Don Guillett" wrote:

the macro recorder is your friend


Cheers
Copied that macro into Macro1, found the number of the chart by putting it
in a window, then changed the macro to this number. This allowed me to name
both charts as I wanted, solving the problem.

I get the feeling this roundabout route wasn't what you had in mind when you
answered, but if it works, it works :p
  #4   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett
 
Posts: n/a
Default Assign charts names in VBA?

It wouldn't be round about IF you already knew the chart names. It could be
done from anywhere in the workbook. If there is only one chart per page you
probably don't need the name.

--
Don Guillett
SalesAid Software

"PaulW" wrote in message
...


"Don Guillett" wrote:

the macro recorder is your friend


Cheers
Copied that macro into Macro1, found the number of the chart by putting it
in a window, then changed the macro to this number. This allowed me to
name
both charts as I wanted, solving the problem.

I get the feeling this roundabout route wasn't what you had in mind when
you
answered, but if it works, it works :p



  #5   Report Post  
Posted to microsoft.public.excel.misc
Jon Peltier
 
Posts: n/a
Default Assign charts names in VBA?

You can also use

activechart.parent.name = "namedchart"

If he charts are created in code, change the name of the chart object when
the chart is being created.

Manually, select a chart using Shift+click. It should have white handles
instead of black, which means you've selected the chart object, a shape
object that serves as a container for an embedded chart. In the Name Box
(top left, next to the formula bar, just below the menus), you'll see a name
like "Chart 55". Change this to whatever name you want and press enter.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

"Don Guillett" wrote in message
...
the macro recorder is your friend
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 5/10/2006 by Don Guillett
'

'
ActiveSheet.Shapes("Chart 2").Select
Selection.Name = "namedchart"
End Sub
shorten to
sheets("sheet2").Shapes("Chart 2").Name = "namedchart"

--
Don Guillett
SalesAid Software

"PaulW" wrote in message
...
Two charts, one on "Options" page, one on "Data" page. Make a simple
macro
that switches the two round.
Recorded a macro, and when I tried to run it I got an error.


ActiveSheet.ChartObjects("Chart 51").Activate
ActiveChart.ChartArea.Select
ActiveChart.Location Whe=xlLocationAsObject, Name:="Data"

Then Chart 24 to "Options". Also recorded the bit where they switch back.
But Chart 24 is now Chart 25, and Chart 51 is now Chart 54. The numbers
seem
to go up each time something is done with a chart... As such, when I try
and
run the macro again the charts have different numbers and it fails.

Can you assign a name to a chart to provent this?







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
multiple charts similar size? [email protected] Charts and Charting in Excel 2 March 10th 06 05:16 PM
Charts: want to assign fixed color for each slice [email protected] Charts and Charting in Excel 1 November 15th 05 07:49 PM
Separating names Danno Excel Worksheet Functions 5 October 31st 05 12:29 AM
find names on list 1 in list 2. list 1 4000 names list 2 400 name Ed Excel Worksheet Functions 1 September 4th 05 12:48 AM
Range Names with Charts ArthurJ Charts and Charting in Excel 3 June 6th 05 06:49 PM


All times are GMT +1. The time now is 03:07 PM.

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

About Us

"It's about Microsoft Excel"