formating charts

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

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Formating charts

Formating charts

resolvedResolved · 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?

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:

Hide separate columns in Excel 2010

If you want to hide columns not adjacent to each other for example, Columns A, C and E then:-

1) Click on the fist column to be hidden i.e. A

2) Press and hold down the CTRL key

3) While holding the CTRL key, left click on the rest of the columns you want to hide i.e. C and E

4) Right click and choose Hide

View all Excel hints and tips


Server loaded in 0.08 secs.