• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Change Order For Chart Series Collection VBA Code|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Change Order For Chart Series Collection VBA Code|VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosChange Order For Chart Series Colle…
sp_PrintTopic sp_TopicIcon
Change Order For Chart Series Collection VBA Code
Avatar
Sivaprakasam Sivaprakasam
Member
Members
Level 0
Forum Posts: 15
Member Since:
February 27, 2020
sp_UserOfflineSmall Offline
1
September 23, 2020 - 12:20 pm
sp_Permalink sp_Print

Hi

I am using the Excel 2013

I have to change in select data the Specify Order For Series collection in Select Data for Chart

=SERIES([Series Name],[X Values],[Y Values],[Plot Order])

I have to change the "Holder" series collection from 5th to 1st move

I actually did something similar. I put "ActiveChart.SeriesCollection(5).PlotOrder = 1" for the first data series, but it doesn't work that way.

when i run the vba code "ActiveChart.SeriesCollection(5).PlotOrder = 1", but this go 3rd position the "Holder".

I don't know, what I am wrong my VBA code... but not working

We need that the "Holder" series move from 5th to 1st position (Untitled image and VBA code Excel enclosed for your reference)

Untitled.pngImage Enlarger

Kindly correction the VBA code

Thanks for Help....

sp_PlupAttachments Attachments
  • sp_PlupImage Untitled.png (116 KB)
Avatar
Miguel Santos
Member
Members
Level 0
Forum Posts: 80
Member Since:
February 20, 2020
sp_UserOfflineSmall Offline
2
September 25, 2020 - 12:34 am
sp_Permalink sp_Print sp_EditHistory

Hello,

If you could load a workbook with a sample, it would be much easier, but I will try to help

a lot of data is missing about how data is organized in your spreadsheet, how it is obtained and what type of chart you are using


example:

1 - assuming you have the data on the sheet and a command button on the sheet (that is, you don't use a user form to display the graph)

2 - I suppose it has only 5 series

3 - I used this type of graph ( xlColumnClustered )

' place the following procedure on the sheet module

Private Sub CommandButton1_Click()

Dim myChartObj As ChartObject

Dim i As Long 

Dim NewChartOrder As Variant ' will be for the new series order

Dim OldChartOrder(0 To 4) As String ' if you have 5 series, you will have to write like this


Application.ThisWorkbook.Worksheets("Sheet1").Activate

If Not ChartExists(Application.ThisWorkbook.Worksheets("Sheet1"), "MyChartName") Then
     ' Chart not exist
     Exit Sub
End If

Set myChartObj = Application.ThisWorkbook.Worksheets("Sheet1").ChartObjects("MyChartName")
myChartObj.Activate

' MsgBox ActiveChart.SeriesCollection.Count     '  if you want to know how many series your chart has

NewChartOrder = Array(5, 1, 2, 3, 4)  ' this will be the order of the series, each time you click the command button, series 5 moves back one position

' if you want to have the order immediately of 5,1,2,3,4 activate the following line of code and disable the previous one to this information

' NewChartOrder = Array(2, 3, 4, 5, 1)

With ActiveChart
     For i = LBound(NewChartOrder) To UBound(NewChartOrder)
          OldChartOrder(i) = .SeriesCollection(i + 1).Name
     Next i
     For i = LBound(NewChartOrder) To UBound(NewChartOrder)
          .SeriesCollection(OldChartOrder(i)).PlotOrder = NewChartOrder(i)
     Next i
End With

If Not myChartObj Is Nothing Then Set myChartObj = Nothing

End Sub

 

' place the following procedure on standart module

Public Function ChartExists(wsTest As Worksheet, strChartName As String) As Boolean '   chart name exist ?

Dim chTest As ChartObject

On Error Resume Next
Set chTest = wsTest.ChartObjects(strChartName)
On Error GoTo 0

If chTest Is Nothing Then
     ChartExists = False
Else
     ChartExists = True
End If

End Function

 

Regards,

 

Miguel

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Louis Muti
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Blair Gallagher
Brandi Taylor
Hafiz Ihsan Qadir
Gontran Bage
adolfo casanova
Annestine Johnpulle
Priscila Campbell
Jeff Mikles
Aaron Butler
Maurice Petterlin
Forum Stats:
Groups: 3
Forums: 24
Topics: 6369
Posts: 27852

 

Member Stats:
Guest Posters: 49
Members: 32359
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.