Solved

Looping thru the SeriesCollection and add data labels

Posted on 2011-03-01
4
949 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
question about excel functionality 3 33
Excel: How to compare data in two columns 17 32
Do Wend Macro not working 22 36
Countdown Timer 2 17
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…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

821 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