formating charts
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

Formating charts

resolvedResolved · Low Priority · Version 2007

replyReply Thu 5 Feb 2009, 17:00Delegate Edward said...

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?

For upcoming training course dates see: Pricing & availability

replyReply Mon 9 Mar 2009, 12:22 Edited on Mon 9 Mar 2009, 12:24Trainer Carlos said...

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.

 

Please browse our web site to find out more about
advanced excel training and other Microsoft training courses.

Excel tip:

Select Single Data Marker

To select a single data marker in a chart, ie line, bar or column;
After you have pressed Ctrl+Click (to select the entire chart) you can press the Up or Down arrows to select a data series, then press the Left or Right arrow to select a data point within that series.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard