98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Formating charts
Formating charts
Resolved · Low Priority · Version 2007
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
Tue 17 Mar 2009: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Hide separate columns in Excel 2010If you want to hide columns not adjacent to each other for example, Columns A, C and E then:- |