Results 1 to 3 of 3

Thread: Updating charts

  1. #1
    Star Lounger
    Join Date
    Mar 2008
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need some help figuring out how to determine if a point on a series collection, If the data label for that point has any value other than 0. So far I'm not able to get it but I think it's because I'm not using the correct properties. Basically need to look through my workbook and find any chart that has a codename starting with the letters "WF". If I find that a chart, then I need to cycle through each series collection and then cycle through each point in that series collection and apply data labels if the point is any value other than 0. I also need to be sure the data label is formatted in bold font and size 12 font. Below is what I have so far. Feel free to make any suggestions to what I have to make this more efficient. I know there is a better way to cycle through each series collection and each point with out having to create a variable (s or p) to name each series collection or point. Thanks for your help!!


    Sub CHART_UPDATES()
    Application.ScreenUpdating = False
    AWB = ActiveWorkbook.Name
    For Each shp In Workbooks(AWB).Charts
    If Left(shp.CodeName, 2) = "WF" Then
    shp.Activate
    s = 1
    ' Need help with this part here
    '------------------------------------------------------------------------------
    For Each sc In ActiveChart.SeriesCollection
    p = 1
    For Each pnt In ActiveChart.SeriesCollection ' I'm sure this is not correct
    ' If the points data label equals 0, hide the data label
    If ActiveChart.SeriesCollection(s).Points(p).DataLabe l.Characters.Text = 0 Then
    ActiveChart.SeriesCollection(s).Points(p).ApplyDat aLabels Type:=xlDataLabelsShowNone
    End If
    ' If the points data label does not equal 0, show the data label
    If ActiveChart.SeriesCollection(s).Points(p).DataLabe l.Characters.Text = 0 Then
    ActiveChart.SeriesCollection(s).Points(p).ApplyDat aLabels Type:=xlDataLabelsShowLabel
    End If
    p = p + 1
    Next pnt
    s = s + 1
    Next sc
    '-------------------------------------------------------------------------
    End If
    Next shp
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try the simplified version in the attached text file.

    [attachment=86558:Code.txt]

    Attached Files Attached Files

  3. #3
    Star Lounger
    Join Date
    Mar 2008
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    Try the simplified version in the attached text file.

    [attachment=86558:Code.txt]

    Hans, Thanks for the suggestion. This looks much better than what I have. I'll give this a try and see if I can't make it work. Thanks again!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •