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
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