Solved

Looping thru the SeriesCollection and add data labels

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

778 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