Re scale primary and secondary y axis using sliders request

J

joecrabtree

To all,

I have an xy chart with a primary and secondary y axis. I would like
to be able to alter the scale of the primary and secondary y axis
independently using sliders ( one for each axis ). How is this
possible? Do I need to write a macro, or is there some other way to
control it?

Thanks in advance for your help,

Regards,

Joseph Crabtree
 
A

Andy Pope

Hi,

That will require VBA code.

Assuming you add 2 scrollbars from the Control Toolbox to the worksheet you
could use the following code.
This will change the primary or Secondary Y axis of the 1st chart object on
the worksheet.

Private Sub ScrollBar1_Change()
' Primary Y Axis
ActiveSheet.ChartObjects(1).Chart.Axes(2, 1).MaximumScale =
ScrollBar1.Value

End Sub

Private Sub ScrollBar2_Change()
' Secondary Y Axis
ActiveSheet.ChartObjects(1).Chart.Axes(2, 2).MaximumScale =
ScrollBar2.Value

End Sub

Cheers
Andy
 
J

joecrabtree

Hi,

That will require VBA code.

Assuming you add 2 scrollbars from the Control Toolbox to the worksheet you
could use the following code.
This will change the primary or Secondary Y axis of the 1st chart object on
the worksheet.

Private Sub ScrollBar1_Change()
' Primary Y Axis
ActiveSheet.ChartObjects(1).Chart.Axes(2, 1).MaximumScale =
ScrollBar1.Value

End Sub

Private Sub ScrollBar2_Change()
' Secondary Y Axis
ActiveSheet.ChartObjects(1).Chart.Axes(2, 2).MaximumScale =
ScrollBar2.Value

End Sub

Cheers
Andy

--








- Show quoted text -

Thanks for that. Is there any way that I can define the minimum as
always 0, and have an upper maximum of 6000?

Thanks
 

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