Xcel charts into Powerpoint

G

Guest

Hi,

I have a excel sheet that has multiple charts in it. There is some vba code
that copies the charts into powerpoint. My problem is that sometimes one
chart and plot area is off a little from a different chart, so when it copies
into powerpoint, it does not look aligned properly. Does anyone know of any
way to force the plot and chart areas to be set the same values for all the
charts on the worksheet, before it gets copied over?

Thanks,

Travis
 
J

Jon Peltier

Travis -

You would need some code to find what are the widest axis limits in the
charts, then apply these to all charts.

For just the Y axis:

Dim Ymin as Double
Dim Ymax as Double
Dim chtob as ChartObject
' initial values ± huge numbers
yMin = 1E300
yMax = -1E300
' find the widest
For Each chtob in ActiveSheet.ChartObjects
If chtob.Chart.Axes(2).MinimumScale < yMin Then
yMin = chtob.Chart.Axes(2).MinimumScale
End If
If chtob.Chart.Axes(2).MaximumScale > yMax Then
yMax = chtob.Chart.Axes(2).MaximumScale
End If
Next
' apply the widest
For Each chtob in ActiveSheet.ChartObjects
chtob.Chart.Axes(2).MinimumScale = yMin
chtob.Chart.Axes(2).MaximumScale = yMax
Next


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

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