need same x and secondary x axis scales

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
 
T

Tushar Mehta

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
 
J

Jon Peltier

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
 
G

Guest

Tushar,

This for the info. I will check it out and let you know
how it worked out.

Jim
 
G

Guest

Jon,

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

Thanks

Jim
 

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