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

graphs

ResolvedVersion 2007

Peter has attended:
Excel VBA Advanced course

Graphs

How is it possible to change the order of your bar labels in a chart using VBA?

RE: Graphs

Hi Peter,

Thank you for the question.

If you create a chart with 3 series, it could be January, February and March. Copy and paste the code below to a module.

Sub ChangeChart()

Dim iCounter As Integer
Dim vNewOrder As Variant
Dim strOldOrder(1 To 3) As String


vNewOrder = Array(3, 1, 2) ' set the order you want.

For iCounter = 1 To UBound(vNewOrder)

strOldOrder(iCounter) = ActiveChart. _
SeriesCollection(i + 1).Name

Next iCounter
For iCounter = 1 To UBound(vNewOrder)

ActiveChart. _
SeriesCollection(strOldOrder(iCounter)). _
PlotOrder = vNewOrder(iCounter)

Next iCounter


End Sub

In the Array function ( Array(3, 1, 2)) just type the order you want for your series.

I hope that helps.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Read more: https://www.stl-training.co.uk/post-34560-formula-shows-quarters.html #ixzz2wE8kbKnu

 

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:

Move data worksheet to worksheet

To move data from one worksheet to another, highlight the data.

Select and hold down the ALT key and position the mouse on the border of the selection until the mouse pointer displays four-headed arrows.

Drag the selection down to the destination worksheet tab.

When the arrow touches the tab, Excel switches to the desired worksheet. Now drag the selection to the correct position. Let go of the mouse and then the ALT key.

To copy data from one worksheet to another, select and hold down the CTRL+ALT keystroke combination and perform the steps above.

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.