Macro to determine chart name

F

Fan924

I have multiple sheets and there is a single chart on each sheet. I
want to use this macro but not all charts are named Chart1. Is there a
way the macro can be made to work no matter what the chart name is?

Sub TestChart()
With ActiveSheet.ChartObjects("Chart 1").Chart.Axes(xlValue)
.MinimumScale = WorksheetFunction.Min(Range("B3:B17"))
.MaximumScale = WorksheetFunction.Max(Range("B3:B17"))
End With
End Sub
 
B

Bob Phillips

Why don't you just select the chart on each sheet and rename it, give them
all the same name.
 
F

Fan924

Why don't you just select the chart on each sheet and rename it, give them
all the same name.

I did think of that. I hane no idea how to rename a chart. How is it
done? Excel97
 
P

Peter T

If you are *sure* each sheet only has one chart
With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
'etc

Otherwise go with Bob's suggestion
(to manually change a chartobject's name:
hold Ctrl+Shift, new name in the Names box left of input bar)

Regards,
Peter T
 
B

Bob Phillips

You can also do it by holding down shift and then click the embedded chart
once. This has the advantage of the cursor changing to an arrow-headed
cross, good visual feedback.


--
__________________________________
HTH

Bob

I did think of that. I hane no idea how to rename a chart. How is it
done? Excel97

I found this and it tells me how to do it. Thanks Bob.
http://support.microsoft.com/kb/169882
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top