Excel Excel and auto scaling primary & secondary axis

Joined
Sep 20, 2010
Messages
1
Reaction score
0
Hi guys/girls,

In the past i have used this marco:

Sub Macro()
Sub selectallcharts()
xmin = InputBox("Input the MINIMUM measured depth", "Min MD")
If xmin = "" Then
Exit Sub
End If
xmax = InputBox("Input the MAXIMUM measured depth", "Max MD")
If xmax = "" Then
Exit Sub
End If
xmin = CInt(xmin)
xmax = CInt(xmax)
If xmin >= xmax Then
MsgBox "You entered a higher min MD than you did max MD"
Exit Sub
End If
response = MsgBox("Would you like to specify a step size for the depth?", vbYesNoCancel)
Select Case response
Case vbCancel
Exit Sub
Case vbNo
unitauto = True
Case vbYes
unitauto = False
xunit = InputBox("Enter the step size for the depth", "Step size")
If xunit = "" Then
Exit Sub
End If
Case Else
End Select
Application.ScreenUpdating = False
Dim mychart As ChartObjects, mysheet As Worksheet
Set mysheet = ActiveSheet
Set mychart = mysheet.ChartObjects

For Each Chart In mychart
Chart.Activate
Chart.Select
With ActiveChart.Axes(xlValue)
.MinimumScale = xmin
.MaximumScale = xmax
If unitauto Then
.MajorUnitIsAuto = True
Else
.MajorUnit = xunit
End If
.Crosses = xlAutomatic
.ReversePlotOrder = True
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Next
End Sub

This has worked well for charts with a single 'primary' axis however I would like to add the option for auto scaling the secndary axis at the same time it rescales the primary axis on the same chart.

Any takers??
Cheers
Frank
 

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