Problem with changing datalabels color after save the file and reopen

tonysarris

New Member
Joined
Feb 7, 2014
Messages
1
Hello,
I need to create some quality reports for my work and run into this "strange problem".
I create some pivot tables from raw data and then create the charts visualizing each pivot table.
Trying to represent with green or red, if the specific platforms we build meet the first pass yield customer demands, i want to change the data label colors of the charts.
Everything works, I can say perfect except the fact that after the code save and close the report and publish it in PDF (so far with no issue), when i reopen the report in the excel format all labels adopt not only the value as was before the save but include "series name","category name" which i do not want.
I copy the part of code that changes the color depends the target value.
It is my first time writing code so please if there is any way improve this let me know.
Thanks in advance

Code:
For HowManyFormFactorLoop = 1 To HowManyFormFactor 'how many actually pivot tables and charts exist. form factor is a group of platforms
    'Mark the red and green points in the chart
    ActiveSheet.ChartObjects(HowManyFormFactorLoop).Activate                              'I activate the chart
    Category = ActiveChart.SeriesCollection(1).XValues                                            'I need the category so i can track the target from a target table
    For CHSeriesCount = 1 To ActiveChart.SeriesCollection.Count                               'looping through the series
        CategoryPoints = ActiveChart.SeriesCollection(CHSeriesCount).Values                'Grab all the data labels values to check if they are above or below the target
        ActiveChart.SeriesCollection(CHSeriesCount).DataLabels.NumberFormat = "0%"
        For i = 1 To UBound(CategoryPoints)                                                            'looping through the data labels for each series
            Target = Application.WorksheetFunction.VLookup(Category(i), WB.Sheets("PlatformsTargets").Range("A1").CurrentRegion, 2, False)
            If CategoryPoints(i) >= Target Then                
                ActiveChart.SeriesCollection(CHSeriesCount).Points(i).DataLabel.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 255, 0)
            Else
                ActiveChart.SeriesCollection(CHSeriesCount).Points(i).DataLabel.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 0, 0)
            End If
        Next i
    Next CHSeriesCount
Next HowManyFormFactorLoop
 
Last edited by a moderator:

Forum statistics

Threads
1,081,802
Messages
5,361,388
Members
400,628
Latest member
ganeshkhatri

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top