Edward has attended:
Excel VBA Intro Intermediate course
Formating charts
Is it possible to set up a macro to format a chart that has a variable axis max/min value?
RE: Formating charts
Hi Edward
Sorry for the delay
The code below takes the active chart and applies the Maximum and Minimum scales as entered by you in dialog boxes.
Sub SetScale()
'
' This macro sets the scale of a chart
'
Dim MaxScale As Integer 'Holds the Maximum value entered
Dim MinScale As Integer 'Holds the Minimum value entered
'To ask for the range I'm using input boxes for ease. You could create a form instead
MaxScale = InputBox("Enter the Maximum scale for the chart")
MinScale = InputBox("Enter the Minimum scale for the chart")
With ActiveChart.Axes(xlValue)
.MinimumScale = MinScale 'eg 0
.MaximumScale = MaxScale 'eg 10000
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub
Copy the above code into your VBE and run it on the chart you want to change, or adapt it to your own code.
Hope this helps
Carlos