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:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top