Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

formating charts

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

Edited on Mon 9 Mar 2009, 12:24

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 courses

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Quickly create a list of numbers

The fill handle in Excel has many uses. If a number is typed into a cell and then the fill handle is used, the number will be copied from one cell to the next.

If you wish to create a list of numbers that increment by one at a time, hold down Ctrl in conjunction with using the fill handle - this should give you a series of numbers (e.g. 1, 2, 3 etc) rather than copying a single number.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.