need same x and secondary x axis scales

  • Thread starter Thread starter Jim Arnold
  • Start date Start date
J

Jim Arnold

I have produced an Excel graph that combines a histogram
(bar chart) with an X-Y chart to allow plotting of
vertical lines showing limits, mean etc. It works great
if I manually set the secondary x-axis to match the values
of the primary x-axis.

In order to make this work for any values plotted, I need
to synchronize the x-axis used for the histogram with the
hidden secondary x-axis used for the x-y (vertical lines)
chart but don't know how to do this automatically.

Is there a Visual basic command(s) to find out the min and
max values of the x-axis and copy these to the values of
the secondary x-axis?

Thanks for your help.

Jim Arnold
 
For a readymade solution, see the AutoChart Manager add-in,
downloadable from my web site.

For code that you can adapt to your own needs check/search Jon
Peltier's www.peltiertech.com.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Jim -

It looks like this:

Sub SameAxes()
With ActiveChart
.Axes(xlCategory, xlSecondary).MinimumScale = _
.Axes(xlCategory, xlPrimary).MinimumScale
.Axes(xlCategory, xlSecondary).MaximumScale = _
.Axes(xlCategory, xlPrimary).MaximumScale
.Axes(xlCategory, xlSecondary).MajorUnit = _
.Axes(xlCategory, xlPrimary).MajorUnit
End With
End Sub

- Jon
 
Jon,

This looks exactly like what I was looking for. I will
test it out and let you know how it worked.

Thanks

Jim
 
Back
Top