Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chart Problems with Recorded Macros

Status
Not open for further replies.

ceecld

Technical User
Jul 17, 2003
68
US
I have used a macro that plot graphs from masses of data then formats the graphs for going straight into reports. When i recorded the macros i plotted the graphs in a particualr order, therefore if i run the macros in another order it doesnt work since the chart numbers are wrong. see code below:


ActiveChart.HasLegend = False
ActiveSheet.Shapes("Chart 2").IncrementLeft 137.25

What i dont understand is why it cant just use the activeChart function for the incrementleft function, rather than activesheet which requires a chart name - e.g. Chart 2 meaning that my graphs have to be plotted in a specific order.

Thanks


Chris Dall

 
Chris Dall,

When you run
Code:
ActiveChart.HasLegend = False
ActiveSheet.Shapes("Chart 2").IncrementLeft 137.25
do all the OTHER charts already exist on the sheet?

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
it depends if you have selected to plot them already, i want to give the user the option of what information the plot rather than having to plot 25 graphs just so you can get the last one in the list.

hope that makes sense
 
Well if you just add the 25th chart on your list, unless you NAMED the chart, Chart 25, it's Chart 1 or Activesheet.Shapes(1)

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
if i made all my plots activesheet.shapes(1) then surely thats not going to work as they will all be called the same thing.

Also the chart wasn't specificaly named excel just labeled them in the order they were created.

 
Basically what im wanting to do is use the ACTIVE chart at that point in time. not a named or otherwise chart
 
???
if i made all my plots activesheet.shapes(1) then surely thats not going to work ...

YOU have not control over this. The first chart that is placed on a sheet is NUMBER ONE in the shapes collection.

If you have more than one chart on the sheet, for instance two, then you have Activesheet.Shapes(1) and Activesheet.Shapes(2)

What's the process here?

Does the user select which chart to plot? If so, then you KNOW which one is on the sheet each time another one is added, right?

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
How about:

ActiveSheet.Shapes(ActiveChart.Parent.Name).IncrementLeft 137.25

Glenn.
 
Thanks GlennUK that was exactly what i was looking for!

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top