Solved

Looping thru the SeriesCollection and add data labels

Posted on 2011-03-01
4
933 Views
Last Modified: 2012-05-11
Dear Experts:

below code snippet creates ...
... Data labels just for just the first! data series of my stacked column chart and formats them

Is it possible to loop through the SeriesCollection and add/format datalabels for all of the Data Series (stacked column chart)?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Sub LoopingThruSeriesCollection()

Dim MyChtObj as ChartObject

With MyChtObj.Chart
    .SeriesCollection(1).ApplyDataLabels
          With .SeriesCollection(1).DataLabels
               .Position = xlLabelPositionInsideEnd
               .Font.Color = RGB(5, 5, 5)
               .Font.Name = "Verdana"
               .Font.Size = 6
               .NumberFormat = "#."
          End With
End With

Open in new window

0
Comment
Question by:AndreasHermle
  • 2
4 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 35009229
Untested, but see if this works:
Sub LoopingThruSeriesCollection()

Dim MyChtObj As ChartObject, i As Long

For i = 1 To ActiveSheet.ChartObjects.Count
    With ActiveSheet.ChartObjects(i).Chart
        .SeriesCollection(1).ApplyDataLabels
        With .SeriesCollection(1).DataLabels
             .Position = xlLabelPositionInsideEnd
             .Font.Color = RGB(5, 5, 5)
             .Font.Name = "Verdana"
             .Font.Size = 6
             .NumberFormat = "#."
        End With
    End With
Next i

End Sub

Open in new window

0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 35009286
Sub LoopingThruSeriesCollection()

Dim MyChtObj as ChartObject
Dim ser as series

With MyChtObj.Chart
    for each ser in .SeriesCollection
       ser.applydatalabels
          With ser.DataLabels
               .Position = xlLabelPositionInsideEnd
               .Font.Color = RGB(5, 5, 5)
               .Font.Name = "Verdana"
               .Font.Size = 6
               .NumberFormat = "#."
          End With
   next ser
End With

Open in new window


I think.
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 35009326
Sorry, I completely failed to read the question properly!
0
 

Author Closing Comment

by:AndreasHermle
ID: 35014952
Dear rorya:
great, thank you very much for your professional help. Regards, Andreas
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now